From 940d8fbe7cfa73e70add75a6771a74ad3a0a5037 Mon Sep 17 00:00:00 2001 From: rongzhang Date: Fri, 18 Oct 2024 15:48:41 +0000 Subject: [PATCH] db: github link alembic migration --- package.json | 2 +- .../versions/a8bb37120302_add_github_link.py | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 querybook/migrations/versions/a8bb37120302_add_github_link.py diff --git a/package.json b/package.json index 8b9712a2d..2387207b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "querybook", - "version": "3.34.2", + "version": "3.35.0", "description": "A Big Data Webapp", "private": true, "scripts": { diff --git a/querybook/migrations/versions/a8bb37120302_add_github_link.py b/querybook/migrations/versions/a8bb37120302_add_github_link.py new file mode 100644 index 000000000..80d0a02d0 --- /dev/null +++ b/querybook/migrations/versions/a8bb37120302_add_github_link.py @@ -0,0 +1,97 @@ +"""Add Github Link + +Revision ID: a8bb37120302 +Revises: f7b11b3e3a95 +Create Date: 2024-10-18 15:50:51.471760 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = 'a8bb37120302' +down_revision = 'f7b11b3e3a95' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('github_link', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('datadoc_id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('repo_url', sa.String(length=255), nullable=False), + sa.Column('branch', sa.String(length=255), nullable=False), + sa.Column('file_path', sa.String(length=255), nullable=False), + sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False), + sa.ForeignKeyConstraint(['datadoc_id'], ['data_doc.id'], ), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('datadoc_id') + ) + op.alter_column('board_editor', 'board_id', + existing_type=mysql.INTEGER(), + nullable=True) + op.alter_column('board_editor', 'uid', + existing_type=mysql.INTEGER(), + nullable=True) + op.drop_constraint('board_item_ibfk_1', 'board_item', type_='foreignkey') + op.create_foreign_key(None, 'board_item', 'board', ['parent_board_id'], ['id']) + op.alter_column('data_doc_dag_export', 'created_at', + existing_type=mysql.DATETIME(), + nullable=False) + op.alter_column('data_doc_dag_export', 'updated_at', + existing_type=mysql.DATETIME(), + nullable=False) + op.alter_column('environment', 'shareable', + existing_type=mysql.TINYINT(display_width=1), + nullable=False, + existing_server_default=sa.text("'1'")) + op.drop_constraint('event_log_ibfk_1', 'event_log', type_='foreignkey') + op.alter_column('user_group_member', 'gid', + existing_type=mysql.INTEGER(), + nullable=True) + op.alter_column('user_group_member', 'uid', + existing_type=mysql.INTEGER(), + nullable=True) + op.alter_column('user_group_member', 'created_at', + existing_type=mysql.DATETIME(), + nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('user_group_member', 'created_at', + existing_type=mysql.DATETIME(), + nullable=False) + op.alter_column('user_group_member', 'uid', + existing_type=mysql.INTEGER(), + nullable=False) + op.alter_column('user_group_member', 'gid', + existing_type=mysql.INTEGER(), + nullable=False) + op.create_foreign_key('event_log_ibfk_1', 'event_log', 'user', ['uid'], ['id']) + op.alter_column('environment', 'shareable', + existing_type=mysql.TINYINT(display_width=1), + nullable=True, + existing_server_default=sa.text("'1'")) + op.alter_column('data_doc_dag_export', 'updated_at', + existing_type=mysql.DATETIME(), + nullable=True) + op.alter_column('data_doc_dag_export', 'created_at', + existing_type=mysql.DATETIME(), + nullable=True) + op.drop_constraint(None, 'board_item', type_='foreignkey') + op.create_foreign_key('board_item_ibfk_1', 'board_item', 'board', ['parent_board_id'], ['id'], ondelete='CASCADE') + op.alter_column('board_editor', 'uid', + existing_type=mysql.INTEGER(), + nullable=False) + op.alter_column('board_editor', 'board_id', + existing_type=mysql.INTEGER(), + nullable=False) + op.drop_table('github_link') + # ### end Alembic commands ###