Skip to content

Commit

Permalink
alembic migration
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangvi7 committed Oct 29, 2024
1 parent 18bd8b3 commit daa18d2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Add GitHub Datadoc Link
Revision ID: aa328ae9dced
Revises: f7b11b3e3a95
Create Date: 2024-10-23 21:04:55.052696
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "aa328ae9dced"
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(
"directory",
sa.String(length=255),
nullable=False,
server_default="datadocs",
),
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"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("github_link")
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion querybook/server/models/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GitHubLink(Base, CRUDMixin):
sql.Integer, sql.ForeignKey("data_doc.id"), nullable=False, unique=True
)
user_id = sql.Column(sql.Integer, sql.ForeignKey("user.id"), nullable=False)
directory = sql.Column(sql.String(255), nullable=False)
directory = sql.Column(sql.String(255), nullable=False, default="datadocs")
created_at = sql.Column(sql.DateTime, server_default=func.now(), nullable=False)
updated_at = sql.Column(
sql.DateTime, server_default=func.now(), onupdate=func.now(), nullable=False
Expand Down

0 comments on commit daa18d2

Please sign in to comment.