Skip to content

Commit ab94c8f

Browse files
committed
fixes test
1 parent e9bba3d commit ab94c8f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/5679165336c8_new_users_secrets.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ def upgrade():
5353

5454

5555
def downgrade():
56+
# Add column as nullable first
5657
op.add_column(
5758
"users",
58-
sa.Column("password_hash", sa.VARCHAR(), autoincrement=False, nullable=False),
59+
sa.Column("password_hash", sa.VARCHAR(), autoincrement=False, nullable=True),
5960
)
6061

6162
# Copy password data back from users_secrets table to users table
@@ -70,4 +71,7 @@ def downgrade():
7071
)
7172
)
7273

74+
# Now make the column NOT NULL
75+
op.alter_column("users", "password_hash", nullable=False)
76+
7377
op.drop_table("users_secrets")

packages/postgres-database/tests/test_users.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ def test_users_secrets_migration_upgrade_downgrade(
249249
"""Tests the migration script that moves password_hash from users to users_secrets table.
250250
251251
252+
testing
253+
packages/postgres-database/src/simcore_postgres_database/migration/versions/5679165336c8_new_users_secrets.py
254+
255+
revision = "5679165336c8"
256+
down_revision = "61b98a60e934"
257+
258+
252259
NOTE: all statements in conn.execute(...) must be sa.text(...) since at that migration point the schemas of the
253260
code models might not be the same
254261
"""
@@ -315,6 +322,7 @@ def test_users_secrets_migration_upgrade_downgrade(
315322
assert password_hashes_before[inserted_user_ids[1]] == "hashed_password_2"
316323

317324
# MIGRATE UPGRADE: this should move password hashes to users_secrets
325+
# packages/postgres-database/src/simcore_postgres_database/migration/versions/5679165336c8_new_users_secrets.py
318326
simcore_postgres_database.cli.upgrade.callback("5679165336c8")
319327

320328
with sync_engine_with_migration.connect() as conn:

0 commit comments

Comments
 (0)