Skip to content

Commit fd6ac0a

Browse files
authored
drop PgSQL 14, unite migration for SQLite and PgSQL (#10165)
1 parent 94941c5 commit fd6ac0a

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

.github/workflows/test-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
fail-fast: false
100100
matrix:
101101
python: ['3.9', '3.12']
102-
pgsql: ['14', '16']
102+
pgsql: ['16', '18']
103103

104104
services:
105105
postgres:

app/alembic_db/versions/0001_assets.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@ def upgrade() -> None:
2626
sa.Column("created_at", sa.DateTime(timezone=False), nullable=False),
2727
sa.CheckConstraint("size_bytes >= 0", name="ck_assets_size_nonneg"),
2828
)
29-
if op.get_bind().dialect.name == "postgresql":
30-
op.create_index(
31-
"uq_assets_hash_not_null",
32-
"assets",
33-
["hash"],
34-
unique=True,
35-
postgresql_where=sa.text("hash IS NOT NULL"),
36-
)
37-
else:
38-
op.create_index("uq_assets_hash", "assets", ["hash"], unique=True)
29+
op.create_index("uq_assets_hash", "assets", ["hash"], unique=True)
3930
op.create_index("ix_assets_mime_type", "assets", ["mime_type"])
4031

4132
# ASSETS_INFO: user-visible references
@@ -179,9 +170,6 @@ def downgrade() -> None:
179170
op.drop_index("ix_assets_info_owner_id", table_name="assets_info")
180171
op.drop_table("assets_info")
181172

182-
if op.get_bind().dialect.name == "postgresql":
183-
op.drop_index("uq_assets_hash_not_null", table_name="assets")
184-
else:
185-
op.drop_index("uq_assets_hash", table_name="assets")
173+
op.drop_index("uq_assets_hash", table_name="assets")
186174
op.drop_index("ix_assets_mime_type", table_name="assets")
187175
op.drop_table("assets")

app/database/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Asset(Base):
7777
)
7878

7979
__table_args__ = (
80+
Index("uq_assets_hash", "hash", unique=True),
8081
Index("ix_assets_mime_type", "mime_type"),
8182
CheckConstraint("size_bytes >= 0", name="ck_assets_size_nonneg"),
8283
)

0 commit comments

Comments
 (0)