feat: split initial social schema migration chain
replace monolithic migration with ordered scripts, include profiles/sessions in migration, and verify full downgrade/upgrade cycle for clean Supabase bootstrap
This commit is contained in:
@@ -3,15 +3,25 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_agent_chat_migration_exists_and_creates_expected_tables() -> None:
|
||||
def test_initial_migration_exists_and_creates_expected_tables() -> None:
|
||||
versions_dir = Path(__file__).resolve().parents[3] / "alembic" / "versions"
|
||||
migration = versions_dir / "20260226_create_agent_chat_core_tables.py"
|
||||
migration_files = sorted(versions_dir.glob("20260226_*.py"))
|
||||
assert len(migration_files) == 5, "split initial migrations should exist"
|
||||
|
||||
assert migration.exists()
|
||||
content = "\n".join(m.read_text(encoding="utf-8") for m in migration_files)
|
||||
|
||||
content = migration.read_text(encoding="utf-8")
|
||||
assert 'create_table(\n "llm_factory"' in content
|
||||
assert 'create_table(\n "llms"' in content
|
||||
assert 'create_table(\n "sessions"' in content
|
||||
assert 'create_table(\n "messages"' in content
|
||||
assert "tool_calls" not in content
|
||||
# New tables from social data model redesign
|
||||
assert "create_table(" in content and "automation_jobs" in content
|
||||
assert "create_table(" in content and "user_agents" in content
|
||||
assert "create_table(" in content and "memories" in content
|
||||
assert "create_table(" in content and "friendships" in content
|
||||
assert "create_table(" in content and "groups" in content
|
||||
assert "create_table(" in content and "group_members" in content
|
||||
assert "create_table(" in content and "schedule_items" in content
|
||||
assert "create_table(" in content and "schedule_subscriptions" in content
|
||||
assert "create_table(" in content and "inbox_messages" in content
|
||||
assert "create_table(" in content and "todos" in content
|
||||
assert "create_table(" in content and "todo_sources" in content
|
||||
assert "create_table(" in content and "profiles" in content
|
||||
assert "create_table(" in content and "sessions" in content
|
||||
assert "create_table(" in content and "messages" in content
|
||||
|
||||
@@ -3,14 +3,13 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_drop_display_name_migration_exists_and_uses_username_metadata() -> None:
|
||||
def test_profiles_has_settings_column() -> None:
|
||||
"""Verify profiles and auth trigger are defined in split migrations."""
|
||||
versions_dir = Path(__file__).resolve().parents[3] / "alembic" / "versions"
|
||||
migration = (
|
||||
versions_dir / "20260224_drop_profile_display_name_and_trigger_username.py"
|
||||
)
|
||||
migration_files = sorted(versions_dir.glob("20260226_*.py"))
|
||||
content = "\n".join(m.read_text(encoding="utf-8") for m in migration_files)
|
||||
|
||||
assert migration.exists()
|
||||
|
||||
content = migration.read_text(encoding="utf-8")
|
||||
assert "DROP COLUMN" in content and "display_name" in content
|
||||
assert "raw_user_meta_data->>'username'" in content
|
||||
assert 'create_table(\n "profiles"' in content
|
||||
assert '"settings"' in content
|
||||
assert "create_profile_for_new_user" in content
|
||||
assert "on_auth_user_created" in content
|
||||
|
||||
Reference in New Issue
Block a user