You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll reproduce the output of the workflow below for reproduction purposes. I have better information, however: I was able to pinpoint why the error was occurring and what to fix -- I just don't know where to make the change.
In migration.py::apply, we read from the database and then partition the migrations into two lists:
with orm.db_session:
applied = set(orm.select(m.name for m in migration_db.Migration))
print(applied)
applied_migrations = [m for m in migrations if m.name in applied]
migrations_to_apply = [m for m in migrations if m.name not in applied]
I added a few print statements to see what was going on, namely this: print('applied vs unapplied: ', applied_migrations, migrations_to_apply)
It revealed that the initial database schema creation was considered already applied: applied vs unapplied: [Migration('0001_initial')] []
This, however, is my best guess as to what is going on. It's possible (better yet likely) that I have a configuration/setup issue and I'm just gung-ho about squashing bugs.
How to Reproduce
Here are the steps I took to reproduce the issue:
Install the migrations branch of pony via ponyorm migration tool #16
Here is my exact version (i.e. from pip list): pony 0.8.dev0
Create entities in a database. I packaged mine in a function called init_db that takes in a configuration dictionary. It does not call bind, generate_mappings, nor connect, it merely defines the entities.
Here is my (approximate) configuration dictionary (for testing):
from <package>.config import TEST
from <package>.entities import init_db
init_db(TEST).migrate(migration_dir=TEST['migration_dir'], **TEST['database'])
Call python migration.py make. Output:
GET NEW CONNECTION
RELEASE CONNECTION
Written: migrations/0001_initial.py
DISCONNECT
In my application an empty sqlite database is created. It has no tables besides the default.
Call python migration.py apply. Output:
GET NEW CONNECTION
RELEASE CONNECTION
GET NEW CONNECTION
RELEASE CONNECTION
GET CONNECTION FROM THE LOCAL POOL
PRAGMA foreign_keys = false
BEGIN IMMEDIATE TRANSACTION
SELECT "migration"."id", "migration"."name", "migration"."applied"
FROM "migration" "migration"
WHERE 0 = 1
COMMIT
PRAGMA foreign_keys = true
CLOSE CONNECTION
GET NEW CONNECTION
SWITCH TO AUTOCOMMIT MODE
SELECT DISTINCT "m"."name"
FROM "migration" "m"
RELEASE CONNECTION
All migrations are applied.
DISCONNECT
DISCONNECT
Notice that All migrations are applied is reached. This means that the database doesn't get initialized -- it considers that migration to already be applied.
Call python migration.py list to confirm:
GET NEW CONNECTION
RELEASE CONNECTION
GET CONNECTION FROM THE LOCAL POOL
SWITCH TO AUTOCOMMIT MODE
SELECT "m"."id", "m"."name", "m"."applied"
FROM "migration" "m"
LIMIT 1
No Migration table. Please apply the initial migration.
RELEASE CONNECTION
DISCONNECT
The text was updated successfully, but these errors were encountered:
Hello, @alxrsngrtn. Thanks for reporting. Seems that you have the same issue as one which was solved here. If it doesn't please respond. Don't forget to update pony from github.
I'll reproduce the output of the workflow below for reproduction purposes. I have better information, however: I was able to pinpoint why the error was occurring and what to fix -- I just don't know where to make the change.
In
migration.py::apply
, we read from the database and then partition the migrations into two lists:I added a few print statements to see what was going on, namely this:
print('applied vs unapplied: ', applied_migrations, migrations_to_apply)
It revealed that the initial database schema creation was considered already applied:
applied vs unapplied: [Migration('0001_initial')] []
This, however, is my best guess as to what is going on. It's possible (better yet likely) that I have a configuration/setup issue and I'm just gung-ho about squashing bugs.
How to Reproduce
Here are the steps I took to reproduce the issue:
Install the migrations branch of pony via ponyorm migration tool #16
Here is my exact version (i.e. from
pip list
):pony 0.8.dev0
Create entities in a database. I packaged mine in a function called
init_db
that takes in a configuration dictionary. It does not callbind
,generate_mappings
, norconnect
, it merely defines the entities.Here is my (approximate) configuration dictionary (for testing):
python migration.py make
. Output:In my application an empty sqlite database is created. It has no tables besides the default.
python migration.py apply
. Output:Notice that
All migrations are applied
is reached. This means that the database doesn't get initialized -- it considers that migration to already be applied.python migration.py list
to confirm:The text was updated successfully, but these errors were encountered: