Skip to content

Commit

Permalink
passing tests for multiple versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MadcowD committed Nov 19, 2024
1 parent 73dbfd3 commit 193e963
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 39 deletions.
1 change: 1 addition & 0 deletions src/ell/stores/migrations/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel
${imports if imports else ""}

# revision identifiers, used by Alembic.
Expand Down

This file was deleted.

6 changes: 2 additions & 4 deletions src/ell/stores/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ class SerializedLMP(SerializedLMPBase, table=True):
secondaryjoin="SerializedLMP.lmp_id==SerializedLMPUses.lmp_user_id",
),
)

class Config:
table_name = "serializedlmp"
# XXX: THis is not a real constraint.
unique_together = [("version_number", "name")]

__table_args__ = (
sa.UniqueConstraint('version_number', 'name', name='uq_serializedlmp_version_number_name'),
)

class InvocationTrace(SQLModel, table=True):
invocation_consumer_id: str = Field(foreign_key="invocation.id", primary_key=True, index=True)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,25 @@ def test_multiple_migrations(temp_db_url):
with engine.connect() as conn:
result = conn.execute(text("SELECT version_num FROM ell_alembic_version"))
version = result.scalar()
assert version == "4524fb60d23e"
assert version

# Downgrade to base
command.downgrade(alembic_cfg, "base")

# Verify no version
with engine.connect() as conn:
result = conn.execute(text("SELECT version_num FROM ell_alembic_version"))
version = result.scalar()
assert version is None
first_version = result.scalar()
assert first_version is None

# Upgrade to head again
command.upgrade(alembic_cfg, "head")

# Verify back at head
with engine.connect() as conn:
result = conn.execute(text("SELECT version_num FROM ell_alembic_version"))
version = result.scalar()
assert version == "4524fb60d23e"
new_version = result.scalar()
assert version == new_version

def test_migration_idempotency(temp_db_url):
"""Test that running migrations multiple times is idempotent"""
Expand Down

0 comments on commit 193e963

Please sign in to comment.