Spaces:
Sleeping
Sleeping
Upload migrations/versions/c5fe90300920_add_parent_id_goto_error.py
Browse files
migrations/versions/c5fe90300920_add_parent_id_goto_error.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Add_parent_id || goto :error
|
| 2 |
+
|
| 3 |
+
Revision ID: c5fe90300920
|
| 4 |
+
Revises: c384fc30b200
|
| 5 |
+
Create Date: 2026-03-09 08:05:12.958743
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = 'c5fe90300920'
|
| 16 |
+
down_revision: Union[str, None] = 'c384fc30b200'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 23 |
+
with op.batch_alter_table('categories', schema=None) as batch_op:
|
| 24 |
+
batch_op.add_column(sa.Column('parent_id', sa.Integer(), nullable=True))
|
| 25 |
+
batch_op.create_foreign_key('fk_categories_parent_id_categories', 'categories', ['parent_id'], ['id'])
|
| 26 |
+
# ### end Alembic commands ###
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def downgrade() -> None:
|
| 30 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 31 |
+
op.drop_constraint(None, 'categories', type_='foreignkey')
|
| 32 |
+
op.drop_column('categories', 'parent_id')
|
| 33 |
+
# ### end Alembic commands ###
|
| 34 |
+
# ### end Alembic commands ###
|