From ab459b4d887f945299d4f4f8938479c1b8ed9a9e Mon Sep 17 00:00:00 2001 From: Brain Date: Fri, 19 Sep 2025 18:09:57 +0200 Subject: [PATCH] Do proper downgrades to reset the database Somehow the table for the alembic migrations was not dropped before, leading to an inconsistent state --- ki/test/ApiTest.py | 3 ++- .../b5023977cbda_extend_skill_length_to_50_chars.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ki/test/ApiTest.py b/ki/test/ApiTest.py index 04c87d9..9112bf3 100644 --- a/ki/test/ApiTest.py +++ b/ki/test/ApiTest.py @@ -31,7 +31,8 @@ class ApiTest(unittest.TestCase): def tearDown(self): with app.app_context(): - db.drop_all() + config = migrate.get_config() + command.downgrade(config, "base") db.engine.dispose() def login(self, username, password): diff --git a/migrations/versions/b5023977cbda_extend_skill_length_to_50_chars.py b/migrations/versions/b5023977cbda_extend_skill_length_to_50_chars.py index 30e181b..87eb4a4 100644 --- a/migrations/versions/b5023977cbda_extend_skill_length_to_50_chars.py +++ b/migrations/versions/b5023977cbda_extend_skill_length_to_50_chars.py @@ -22,3 +22,10 @@ def upgrade(): existing_type=sa.VARCHAR(length=25), type_=sa.String(length=50), existing_nullable=False) + +def downgrade(): + with op.batch_alter_table("skill") as batch_op: + batch_op.alter_column('name', + existing_type=sa.String(length=50), + type_=sa.VARCHAR(length=25), + existing_nullable=False)