diff --git a/Makefile b/Makefile index ad5172a..9b687e9 100644 --- a/Makefile +++ b/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" \ No newline at end of file diff --git a/backend/migrations/versions/bbee168ba406_.py b/backend/migrations/versions/bbee168ba406_.py deleted file mode 100644 index c9dea54..0000000 --- a/backend/migrations/versions/bbee168ba406_.py +++ /dev/null @@ -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 ### diff --git a/backend/migrations/versions/fe01918a1b80_initial_migration.py b/backend/migrations/versions/fe01918a1b80_initial_migration.py new file mode 100644 index 0000000..514deaf --- /dev/null +++ b/backend/migrations/versions/fe01918a1b80_initial_migration.py @@ -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 ###