litestar-org/litestar-fullstack

Alembic is not correctly configured

0xSwego opened this issue · 2 comments

It seems that whenever one tries to generate new migrations, Alembic does not see the models and drops the tables (or returns an empty migration file if generating the initial migration).

Steps to reproduce

  1. Clone repo
  2. make install
  3. poetry install
  4. poetry run app database create-database
  5. make migrations

At this point, Alembic should see no changes, thus create an empty migration file. Instead, it creates a migration file in which all tables are dropped.

Logs:

make migrations
ATTENTION: This operation will create a new database migration for any defined models changes.
Migration message: whatevs
2023-08-08T15:48:05.052365Z [info     ] Context impl PostgresqlImpl.
2023-08-08T15:48:05.052742Z [info     ] Will assume transactional DDL.
2023-08-08T15:48:07.309490Z [info     ] Detected removed index 'ix_team_invitation_email' on 'team_invitation'
2023-08-08T15:48:07.310093Z [info     ] Detected removed table 'team_invitation'
2023-08-08T15:48:07.749287Z [info     ] Detected removed index 'ix_team_member_role' on 'team_member'
2023-08-08T15:48:07.749680Z [info     ] Detected removed table 'team_member'
2023-08-08T15:48:08.608711Z [info     ] Detected removed table 'team_tag'
2023-08-08T15:48:08.738695Z [info     ] Detected removed table 'user_account'
2023-08-08T15:48:08.865892Z [info     ] Detected removed table 'tag'
2023-08-08T15:48:08.995045Z [info     ] Detected removed index 'ix_team_name' on 'team'
2023-08-08T15:48:08.995544Z [info     ] Detected removed index 'ix_team_slug' on 'team'
2023-08-08T15:48:08.995788Z [info     ] Detected removed table 'team'
  Generating /home/x/projects/litestar-fullstack/src/app/lib/db/migrations/versions/2023-08-08_whatevs_cdd6bd1ce53b.py
  ...  done
cofin commented

Hi - the issue was introduced when I emptied out the __init__.py in src/app/.

I've since re-added it. Can you confirm if this resolves the issue?

Yes the issue is resolved, thanks!