Set the initial migration better
This commit is contained in:
parent
0d1e53acdb
commit
03aba52c6c
4
Makefile
4
Makefile
@ -22,11 +22,13 @@ clean-db:
|
||||
clean:
|
||||
rm -rf $(VENV_DIR)
|
||||
|
||||
start-db:
|
||||
docker compose up -d db
|
||||
|
||||
create-migration:
|
||||
@read -p "Enter migration message: " MESSAGE; \
|
||||
if [ -z "$$MESSAGE" ]; then \
|
||||
echo "Migration message cannot be empty."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
docker compose up -d db
|
||||
cd backend && alembic revision --autogenerate -m "$$MESSAGE"
|
||||
@ -1,49 +0,0 @@
|
||||
"""
|
||||
|
||||
Revision ID: bbee168ba406
|
||||
Revises:
|
||||
Create Date: 2025-02-19 15:48:47.075283
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'bbee168ba406'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('house')
|
||||
op.drop_table('owner')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('owner',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name='owner_user_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='owner_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('house',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('address', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('city', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('country', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
|
||||
sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('owner_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.ForeignKeyConstraint(['owner_id'], ['owner.id'], name='house_owner_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='house_pkey')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
@ -0,0 +1,37 @@
|
||||
"""Initial migration
|
||||
|
||||
Revision ID: fe01918a1b80
|
||||
Revises:
|
||||
Create Date: 2025-02-19 15:58:55.333850
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel.sql.sqltypes
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'fe01918a1b80'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('user',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('password_hash', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('user')
|
||||
# ### end Alembic commands ###
|
||||
Loading…
x
Reference in New Issue
Block a user