forked from pinterest/querybook
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: comment alembic migration (pinterest#1252)
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
querybook/migrations/versions/3d9f98ca7ec1_add_comment_feature.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
from .tag import * | ||
from .event_log import * | ||
from .data_element import * | ||
from .comment import * |