Skip to content

Commit

Permalink
db: comment alembic migration (pinterest#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
meowcodes committed Jun 23, 2023
1 parent eda9d08 commit a72bd53
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "querybook",
"version": "3.23.2",
"version": "3.24.0",
"description": "A Big Data Webapp",
"private": true,
"scripts": {
Expand Down
74 changes: 74 additions & 0 deletions querybook/migrations/versions/3d9f98ca7ec1_add_comment_feature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""add comment feature
Revision ID: 3d9f98ca7ec1
Revises: 7f6cdb3621f7
Create Date: 2023-05-22 22:06:30.972865
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "3d9f98ca7ec1"
down_revision = "7f6cdb3621f7"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"comment",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("created_by", sa.Integer(), nullable=True),
sa.Column("text", sa.Text(length=16777215), nullable=True),
sa.Column("parent_comment_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(
["parent_comment_id"], ["comment.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"comment_reaction",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("comment_id", sa.Integer(), nullable=False),
sa.Column("reaction", sa.String(length=255), nullable=False),
sa.Column("created_by", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(["comment_id"], ["comment.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"data_cell_comment",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("data_cell_id", sa.Integer(), nullable=False),
sa.Column("comment_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(["comment_id"], ["comment.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["data_cell_id"], ["data_cell.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"data_table_comment",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("data_table_id", sa.Integer(), nullable=False),
sa.Column("comment_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(["comment_id"], ["comment.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(
["data_table_id"], ["data_table.id"], ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("data_table_comment")
op.drop_table("data_cell_comment")
op.drop_table("comment_reaction")
op.drop_table("comment")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions querybook/server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
from .tag import *
from .event_log import *
from .data_element import *
from .comment import *

0 comments on commit a72bd53

Please sign in to comment.