Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint("record_id"),
)
op.create_index(
"launchplane_merge_train_stack_collapse_plans_repository_base_idx",
"launchplane_merge_train_stack_collapse_repository_base_idx",
"launchplane_merge_train_stack_collapse_plans",
["repository", "base_branch", sa.text("updated_at DESC")],
)
Expand All @@ -56,7 +56,7 @@ def downgrade() -> None:
table_name="launchplane_merge_train_stack_collapse_plans",
)
op.drop_index(
"launchplane_merge_train_stack_collapse_plans_repository_base_idx",
"launchplane_merge_train_stack_collapse_repository_base_idx",
table_name="launchplane_merge_train_stack_collapse_plans",
)
op.drop_table("launchplane_merge_train_stack_collapse_plans")
2 changes: 1 addition & 1 deletion control_plane/storage/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ class LaunchplaneMergeTrainStackCollapsePlanRow(Base):
__tablename__ = "launchplane_merge_train_stack_collapse_plans"
__table_args__ = (
Index(
"launchplane_merge_train_stack_collapse_plans_repository_base_idx",
"launchplane_merge_train_stack_collapse_repository_base_idx",
"repository",
"base_branch",
desc("updated_at"),
Expand Down
17 changes: 16 additions & 1 deletion tests/test_postgres_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from alembic.config import Config as AlembicConfig
from click.testing import CliRunner
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.sql.schema import Index

from control_plane.cli import main
from control_plane.contracts.artifact_identity import (
Expand Down Expand Up @@ -113,7 +114,7 @@
)
from control_plane.service_human_auth import LaunchplaneHumanSession
from control_plane.storage.filesystem import FilesystemRecordStore
from control_plane.storage.postgres import PostgresRecordStore
from control_plane.storage.postgres import Base, PostgresRecordStore
from tests.merge_train_policy_fixtures import build_test_merge_train_policy
from tests.merge_train_policy_fixtures import build_test_merge_train_policy_with_codex_skills

Expand Down Expand Up @@ -699,6 +700,20 @@ def _merge_train_stack_collapse_plan_record(


class PostgresRecordStoreTests(unittest.TestCase):
def test_postgres_metadata_index_names_fit_identifier_limit(self) -> None:
index_names = tuple(
index.name
for table in Base.metadata.tables.values()
for index in table.indexes
if isinstance(index, Index) and index.name is not None
)

too_long_index_names = tuple(
index_name for index_name in index_names if len(index_name) > 63
)

self.assertEqual(too_long_index_names, ())

def test_alembic_baseline_creates_schema_used_by_record_store(self) -> None:
with TemporaryDirectory() as temporary_directory_name:
database_url = _sqlite_database_url(
Expand Down