@weirdfingers/baseboards 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +560 -469
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
- package/templates/README.md +0 -122
- package/templates/api/.env.example +0 -65
- package/templates/api/ARTIFACT_RESOLUTION_GUIDE.md +0 -148
- package/templates/api/Dockerfile +0 -32
- package/templates/api/README.md +0 -264
- package/templates/api/alembic/env.py +0 -114
- package/templates/api/alembic/script.py.mako +0 -28
- package/templates/api/alembic/versions/20250101_000000_initial_schema.py +0 -506
- package/templates/api/alembic/versions/20251022_174729_remove_provider_name_from_generations.py +0 -75
- package/templates/api/alembic/versions/20251023_165852_switch_to_declarative_base_and_mapping.py +0 -467
- package/templates/api/alembic/versions/20251202_000000_add_artifact_lineage.py +0 -134
- package/templates/api/alembic/versions/2025925_62735_add_seed_data_for_default_tenant.py +0 -88
- package/templates/api/alembic.ini +0 -36
- package/templates/api/config/generators.yaml +0 -237
- package/templates/api/config/storage_config.yaml +0 -26
- package/templates/api/docs/ADDING_GENERATORS.md +0 -409
- package/templates/api/docs/GENERATORS_API.md +0 -502
- package/templates/api/docs/MIGRATIONS.md +0 -472
- package/templates/api/docs/TESTING_LIVE_APIS.md +0 -417
- package/templates/api/docs/storage_providers.md +0 -337
- package/templates/api/pyproject.toml +0 -205
- package/templates/api/src/boards/__init__.py +0 -10
- package/templates/api/src/boards/api/app.py +0 -172
- package/templates/api/src/boards/api/auth.py +0 -75
- package/templates/api/src/boards/api/endpoints/__init__.py +0 -3
- package/templates/api/src/boards/api/endpoints/jobs.py +0 -76
- package/templates/api/src/boards/api/endpoints/setup.py +0 -505
- package/templates/api/src/boards/api/endpoints/sse.py +0 -129
- package/templates/api/src/boards/api/endpoints/storage.py +0 -155
- package/templates/api/src/boards/api/endpoints/tenant_registration.py +0 -296
- package/templates/api/src/boards/api/endpoints/uploads.py +0 -149
- package/templates/api/src/boards/api/endpoints/webhooks.py +0 -13
- package/templates/api/src/boards/auth/__init__.py +0 -15
- package/templates/api/src/boards/auth/adapters/__init__.py +0 -27
- package/templates/api/src/boards/auth/adapters/auth0.py +0 -220
- package/templates/api/src/boards/auth/adapters/base.py +0 -73
- package/templates/api/src/boards/auth/adapters/clerk.py +0 -172
- package/templates/api/src/boards/auth/adapters/jwt.py +0 -122
- package/templates/api/src/boards/auth/adapters/none.py +0 -102
- package/templates/api/src/boards/auth/adapters/oidc.py +0 -284
- package/templates/api/src/boards/auth/adapters/supabase.py +0 -110
- package/templates/api/src/boards/auth/context.py +0 -35
- package/templates/api/src/boards/auth/factory.py +0 -129
- package/templates/api/src/boards/auth/middleware.py +0 -221
- package/templates/api/src/boards/auth/provisioning.py +0 -129
- package/templates/api/src/boards/auth/tenant_extraction.py +0 -278
- package/templates/api/src/boards/cli.py +0 -354
- package/templates/api/src/boards/config.py +0 -131
- package/templates/api/src/boards/database/__init__.py +0 -7
- package/templates/api/src/boards/database/cli.py +0 -110
- package/templates/api/src/boards/database/connection.py +0 -292
- package/templates/api/src/boards/database/models.py +0 -19
- package/templates/api/src/boards/database/seed_data.py +0 -182
- package/templates/api/src/boards/dbmodels/__init__.py +0 -441
- package/templates/api/src/boards/generators/__init__.py +0 -57
- package/templates/api/src/boards/generators/artifact_resolution.py +0 -405
- package/templates/api/src/boards/generators/artifacts.py +0 -53
- package/templates/api/src/boards/generators/base.py +0 -144
- package/templates/api/src/boards/generators/implementations/__init__.py +0 -14
- package/templates/api/src/boards/generators/implementations/fal/__init__.py +0 -25
- package/templates/api/src/boards/generators/implementations/fal/audio/__init__.py +0 -23
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_music_generation.py +0 -171
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_sound_effect_generation.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_text_to_speech.py +0 -176
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_tts_turbo.py +0 -195
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_sound_effects_v2.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_tts_eleven_v3.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_elevenlabs_tts_turbo_v2_5.py +0 -206
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_minimax_speech_26_hd.py +0 -237
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_music_v2.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_speech_2_6_turbo.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/__init__.py +0 -63
- package/templates/api/src/boards/generators/implementations/fal/image/bytedance_seedream_v45_edit.py +0 -219
- package/templates/api/src/boards/generators/implementations/fal/image/clarity_upscaler.py +0 -220
- package/templates/api/src/boards/generators/implementations/fal/image/crystal_upscaler.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/image/fal_ideogram_character.py +0 -227
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2.py +0 -203
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_edit.py +0 -230
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro.py +0 -204
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro_edit.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_kontext.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_ultra.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image_edit.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_15_edit.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_5.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_edit_image.py +0 -182
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_mini.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_character_edit.py +0 -299
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_v2.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview_fast.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_edit.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro_edit.py +0 -226
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image.py +0 -249
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image_edit.py +0 -244
- package/templates/api/src/boards/generators/implementations/fal/image/reve_edit.py +0 -178
- package/templates/api/src/boards/generators/implementations/fal/image/reve_text_to_image.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/image/seedream_v45_text_to_image.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/utils.py +0 -61
- package/templates/api/src/boards/generators/implementations/fal/video/__init__.py +0 -77
- package/templates/api/src/boards/generators/implementations/fal/video/bytedance_seedance_v1_pro_text_to_video.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/video/creatify_lipsync.py +0 -161
- package/templates/api/src/boards/generators/implementations/fal/video/fal_bytedance_seedance_v1_pro_image_to_video.py +0 -222
- package/templates/api/src/boards/generators/implementations/fal/video/fal_minimax_hailuo_02_standard_text_to_video.py +0 -152
- package/templates/api/src/boards/generators/implementations/fal/video/fal_pixverse_lipsync.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/video/fal_sora_2_text_to_video.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/video/infinitalk.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_pro.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_standard.py +0 -159
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_image_to_video.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_text_to_video.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/minimax_hailuo_2_3_pro_image_to_video.py +0 -153
- package/templates/api/src/boards/generators/implementations/fal/video/sora2_image_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_image_to_video_pro.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_text_to_video_pro.py +0 -163
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2_pro.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/video/veed_fabric_1_0.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/video/veed_lipsync.py +0 -174
- package/templates/api/src/boards/generators/implementations/fal/video/veo3.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/video/veo31.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast_image_to_video.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_first_last_frame_to_video.py +0 -187
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_image_to_video.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_reference_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_image_to_video.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_text_to_video.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/video/wan_pro_image_to_video.py +0 -158
- package/templates/api/src/boards/generators/implementations/kie/__init__.py +0 -11
- package/templates/api/src/boards/generators/implementations/kie/base.py +0 -316
- package/templates/api/src/boards/generators/implementations/kie/image/__init__.py +0 -3
- package/templates/api/src/boards/generators/implementations/kie/image/nano_banana_edit.py +0 -190
- package/templates/api/src/boards/generators/implementations/kie/utils.py +0 -98
- package/templates/api/src/boards/generators/implementations/kie/video/__init__.py +0 -8
- package/templates/api/src/boards/generators/implementations/kie/video/veo3.py +0 -161
- package/templates/api/src/boards/generators/implementations/openai/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/whisper.py +0 -69
- package/templates/api/src/boards/generators/implementations/openai/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/image/dalle3.py +0 -96
- package/templates/api/src/boards/generators/implementations/replicate/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/flux_pro.py +0 -88
- package/templates/api/src/boards/generators/implementations/replicate/video/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/video/lipsync.py +0 -73
- package/templates/api/src/boards/generators/loader.py +0 -253
- package/templates/api/src/boards/generators/registry.py +0 -114
- package/templates/api/src/boards/generators/resolution.py +0 -632
- package/templates/api/src/boards/generators/testmods/class_gen.py +0 -34
- package/templates/api/src/boards/generators/testmods/import_side_effect.py +0 -35
- package/templates/api/src/boards/graphql/__init__.py +0 -7
- package/templates/api/src/boards/graphql/access_control.py +0 -136
- package/templates/api/src/boards/graphql/mutations/root.py +0 -148
- package/templates/api/src/boards/graphql/queries/root.py +0 -116
- package/templates/api/src/boards/graphql/resolvers/__init__.py +0 -8
- package/templates/api/src/boards/graphql/resolvers/auth.py +0 -12
- package/templates/api/src/boards/graphql/resolvers/board.py +0 -1053
- package/templates/api/src/boards/graphql/resolvers/generation.py +0 -666
- package/templates/api/src/boards/graphql/resolvers/generator.py +0 -50
- package/templates/api/src/boards/graphql/resolvers/lineage.py +0 -381
- package/templates/api/src/boards/graphql/resolvers/upload.py +0 -463
- package/templates/api/src/boards/graphql/resolvers/user.py +0 -25
- package/templates/api/src/boards/graphql/schema.py +0 -81
- package/templates/api/src/boards/graphql/types/board.py +0 -102
- package/templates/api/src/boards/graphql/types/generation.py +0 -166
- package/templates/api/src/boards/graphql/types/generator.py +0 -17
- package/templates/api/src/boards/graphql/types/user.py +0 -47
- package/templates/api/src/boards/jobs/repository.py +0 -153
- package/templates/api/src/boards/logging.py +0 -195
- package/templates/api/src/boards/middleware.py +0 -339
- package/templates/api/src/boards/progress/__init__.py +0 -4
- package/templates/api/src/boards/progress/models.py +0 -25
- package/templates/api/src/boards/progress/publisher.py +0 -64
- package/templates/api/src/boards/py.typed +0 -0
- package/templates/api/src/boards/redis_pool.py +0 -118
- package/templates/api/src/boards/storage/__init__.py +0 -52
- package/templates/api/src/boards/storage/base.py +0 -363
- package/templates/api/src/boards/storage/config.py +0 -187
- package/templates/api/src/boards/storage/factory.py +0 -288
- package/templates/api/src/boards/storage/implementations/__init__.py +0 -27
- package/templates/api/src/boards/storage/implementations/gcs.py +0 -340
- package/templates/api/src/boards/storage/implementations/local.py +0 -201
- package/templates/api/src/boards/storage/implementations/s3.py +0 -294
- package/templates/api/src/boards/storage/implementations/supabase.py +0 -218
- package/templates/api/src/boards/tenant_isolation.py +0 -446
- package/templates/api/src/boards/validation.py +0 -262
- package/templates/api/src/boards/workers/__init__.py +0 -1
- package/templates/api/src/boards/workers/actors.py +0 -274
- package/templates/api/src/boards/workers/cli.py +0 -125
- package/templates/api/src/boards/workers/context.py +0 -348
- package/templates/api/src/boards/workers/middleware.py +0 -58
- package/templates/api/src/py.typed +0 -0
- package/templates/compose.web.yaml +0 -35
- package/templates/compose.yaml +0 -116
- package/templates/docker/env.example +0 -23
- package/templates/web/.env.example +0 -28
- package/templates/web/Dockerfile +0 -51
- package/templates/web/components.json +0 -22
- package/templates/web/imageLoader.js +0 -18
- package/templates/web/next-env.d.ts +0 -5
- package/templates/web/next.config.js +0 -36
- package/templates/web/package.json +0 -41
- package/templates/web/postcss.config.mjs +0 -7
- package/templates/web/public/favicon.ico +0 -0
- package/templates/web/src/app/boards/[boardId]/page.tsx +0 -353
- package/templates/web/src/app/globals.css +0 -123
- package/templates/web/src/app/layout.tsx +0 -31
- package/templates/web/src/app/lineage/[generationId]/page.tsx +0 -235
- package/templates/web/src/app/page.tsx +0 -35
- package/templates/web/src/app/providers.tsx +0 -18
- package/templates/web/src/components/boards/ArtifactInputSlots.tsx +0 -206
- package/templates/web/src/components/boards/ArtifactPreview.tsx +0 -466
- package/templates/web/src/components/boards/GenerationGrid.tsx +0 -282
- package/templates/web/src/components/boards/GenerationInput.tsx +0 -370
- package/templates/web/src/components/boards/GeneratorSelector.tsx +0 -272
- package/templates/web/src/components/boards/UploadArtifact.tsx +0 -563
- package/templates/web/src/components/header.tsx +0 -32
- package/templates/web/src/components/theme-provider.tsx +0 -10
- package/templates/web/src/components/theme-toggle.tsx +0 -75
- package/templates/web/src/components/ui/alert-dialog.tsx +0 -157
- package/templates/web/src/components/ui/button.tsx +0 -58
- package/templates/web/src/components/ui/card.tsx +0 -92
- package/templates/web/src/components/ui/dropdown-menu.tsx +0 -200
- package/templates/web/src/components/ui/navigation-menu.tsx +0 -168
- package/templates/web/src/components/ui/toast.tsx +0 -128
- package/templates/web/src/components/ui/toaster.tsx +0 -35
- package/templates/web/src/components/ui/use-toast.ts +0 -187
- package/templates/web/src/hooks/useGeneratorMRU.ts +0 -57
- package/templates/web/src/lib/utils.ts +0 -6
- package/templates/web/tsconfig.json +0 -41
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import asyncio
|
|
4
|
-
import sys
|
|
5
|
-
from logging.config import fileConfig
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
from sqlalchemy import pool, text
|
|
9
|
-
from sqlalchemy.engine import Connection
|
|
10
|
-
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
|
11
|
-
|
|
12
|
-
from alembic import context # type: ignore[reportMissingImports]
|
|
13
|
-
|
|
14
|
-
# Ensure backend src/ is on sys.path so imports work when running Alembic
|
|
15
|
-
BASE_DIR = Path(__file__).resolve().parents[1]
|
|
16
|
-
SRC_DIR = BASE_DIR / "src"
|
|
17
|
-
if str(SRC_DIR) not in sys.path:
|
|
18
|
-
sys.path.insert(0, str(SRC_DIR))
|
|
19
|
-
|
|
20
|
-
from boards.config import settings # type: ignore
|
|
21
|
-
from boards.dbmodels import target_metadata # type: ignore
|
|
22
|
-
|
|
23
|
-
# this is the Alembic Config object, which provides
|
|
24
|
-
# access to the values within the .ini file in use.
|
|
25
|
-
config = context.config
|
|
26
|
-
|
|
27
|
-
# Interpret the config file for Python logging.
|
|
28
|
-
# This line sets up loggers basically.
|
|
29
|
-
if config.config_file_name is not None:
|
|
30
|
-
fileConfig(config.config_file_name)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def get_sync_url() -> str:
|
|
34
|
-
# Use the same logic as get_database_url() from the application
|
|
35
|
-
# Check environment variables first, then fall back to settings
|
|
36
|
-
import os
|
|
37
|
-
|
|
38
|
-
db_url = os.getenv("BOARDS_DATABASE_URL")
|
|
39
|
-
if not db_url:
|
|
40
|
-
# For tests that set env vars after settings are loaded
|
|
41
|
-
if "BOARDS_DATABASE_URL" in os.environ:
|
|
42
|
-
db_url = os.environ["BOARDS_DATABASE_URL"]
|
|
43
|
-
else:
|
|
44
|
-
db_url = settings.database_url
|
|
45
|
-
return db_url
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def get_async_url() -> str:
|
|
49
|
-
url = get_sync_url()
|
|
50
|
-
if url.startswith("postgresql://"):
|
|
51
|
-
return url.replace("postgresql://", "postgresql+asyncpg://")
|
|
52
|
-
return url
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def run_migrations_offline() -> None:
|
|
56
|
-
"""
|
|
57
|
-
Run migrations in 'offline' mode.
|
|
58
|
-
|
|
59
|
-
This configures the context with just a URL
|
|
60
|
-
and not an Engine, though an Engine is acceptable
|
|
61
|
-
here as well. By skipping the Engine creation
|
|
62
|
-
we don't even need a DBAPI to be available.
|
|
63
|
-
"""
|
|
64
|
-
sync_url = get_sync_url()
|
|
65
|
-
context.configure(
|
|
66
|
-
url=sync_url,
|
|
67
|
-
target_metadata=target_metadata,
|
|
68
|
-
literal_binds=True,
|
|
69
|
-
compare_type=True,
|
|
70
|
-
dialect_opts={"paramstyle": "named"},
|
|
71
|
-
include_schemas=True,
|
|
72
|
-
# Keep alembic_version in public schema for easier lifecycle management
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
with context.begin_transaction():
|
|
76
|
-
context.run_migrations()
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def do_run_migrations(connection: Connection) -> None:
|
|
80
|
-
# Ensure the boards schema exists before creating tables
|
|
81
|
-
connection.execute(text("CREATE SCHEMA IF NOT EXISTS boards"))
|
|
82
|
-
connection.commit()
|
|
83
|
-
|
|
84
|
-
context.configure(
|
|
85
|
-
connection=connection,
|
|
86
|
-
target_metadata=target_metadata,
|
|
87
|
-
compare_type=True,
|
|
88
|
-
render_as_batch=False,
|
|
89
|
-
include_schemas=True,
|
|
90
|
-
# Keep alembic_version in public schema for easier lifecycle management
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
with context.begin_transaction():
|
|
94
|
-
context.run_migrations()
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
async def run_migrations_online() -> None:
|
|
98
|
-
"""
|
|
99
|
-
Run migrations in 'online' mode with AsyncEngine.
|
|
100
|
-
"""
|
|
101
|
-
connectable: AsyncEngine = create_async_engine(
|
|
102
|
-
get_async_url(), poolclass=pool.NullPool
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
async with connectable.connect() as connection:
|
|
106
|
-
await connection.run_sync(do_run_migrations)
|
|
107
|
-
|
|
108
|
-
await connectable.dispose()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if context.is_offline_mode():
|
|
112
|
-
run_migrations_offline()
|
|
113
|
-
else:
|
|
114
|
-
asyncio.run(run_migrations_online())
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"""${message}
|
|
2
|
-
|
|
3
|
-
Revision ID: ${up_revision}
|
|
4
|
-
Revises: ${down_revision | comma,n}
|
|
5
|
-
Create Date: ${create_date}
|
|
6
|
-
|
|
7
|
-
"""
|
|
8
|
-
from typing import Sequence, Union
|
|
9
|
-
|
|
10
|
-
from alembic import op
|
|
11
|
-
import sqlalchemy as sa
|
|
12
|
-
${imports if imports else ""}
|
|
13
|
-
|
|
14
|
-
# revision identifiers, used by Alembic.
|
|
15
|
-
revision: str = ${repr(up_revision)}
|
|
16
|
-
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
|
17
|
-
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
|
18
|
-
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def upgrade() -> None:
|
|
22
|
-
"""Upgrade schema."""
|
|
23
|
-
${upgrades if upgrades else "pass"}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def downgrade() -> None:
|
|
27
|
-
"""Downgrade schema."""
|
|
28
|
-
${downgrades if downgrades else "pass"}
|
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Initial schema with uuid-ossp extension and core tables.
|
|
3
|
-
|
|
4
|
-
Revision ID: 20250101_000000_initial_schema
|
|
5
|
-
Revises:
|
|
6
|
-
Create Date: 2025-01-01 00:00:00
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import sqlalchemy as sa
|
|
10
|
-
from sqlalchemy.dialects import postgresql
|
|
11
|
-
|
|
12
|
-
from alembic import op # type: ignore[reportMissingImports]
|
|
13
|
-
|
|
14
|
-
# revision identifiers, used by Alembic.
|
|
15
|
-
revision = "20250101_000000_initial_schema"
|
|
16
|
-
down_revision = None
|
|
17
|
-
branch_labels = None
|
|
18
|
-
depends_on = None
|
|
19
|
-
|
|
20
|
-
# Schema name for all Boards tables
|
|
21
|
-
SCHEMA = "boards"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def upgrade() -> None:
|
|
25
|
-
# Create the boards schema
|
|
26
|
-
op.execute(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA};")
|
|
27
|
-
|
|
28
|
-
# Required extension for uuid_generate_v4 (in public schema, accessible everywhere)
|
|
29
|
-
op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
|
|
30
|
-
|
|
31
|
-
# tenants
|
|
32
|
-
op.create_table(
|
|
33
|
-
"tenants",
|
|
34
|
-
sa.Column(
|
|
35
|
-
"id",
|
|
36
|
-
postgresql.UUID(as_uuid=False),
|
|
37
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
38
|
-
),
|
|
39
|
-
sa.Column("name", sa.String(length=255), nullable=False),
|
|
40
|
-
sa.Column("slug", sa.String(length=255), nullable=False),
|
|
41
|
-
sa.Column(
|
|
42
|
-
"settings",
|
|
43
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
44
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
45
|
-
),
|
|
46
|
-
sa.Column(
|
|
47
|
-
"created_at",
|
|
48
|
-
sa.DateTime(timezone=True),
|
|
49
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
50
|
-
),
|
|
51
|
-
sa.Column(
|
|
52
|
-
"updated_at",
|
|
53
|
-
sa.DateTime(timezone=True),
|
|
54
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
55
|
-
),
|
|
56
|
-
sa.PrimaryKeyConstraint("id", name="tenants_pkey"),
|
|
57
|
-
sa.UniqueConstraint("slug", name="tenants_slug_key"),
|
|
58
|
-
schema=SCHEMA,
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
# provider_configs
|
|
62
|
-
op.create_table(
|
|
63
|
-
"provider_configs",
|
|
64
|
-
sa.Column(
|
|
65
|
-
"id",
|
|
66
|
-
postgresql.UUID(as_uuid=False),
|
|
67
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
68
|
-
),
|
|
69
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
70
|
-
sa.Column("provider_name", sa.String(length=100), nullable=False),
|
|
71
|
-
sa.Column("config", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
|
72
|
-
sa.Column("is_enabled", sa.Boolean(), server_default=sa.text("true")),
|
|
73
|
-
sa.Column(
|
|
74
|
-
"created_at",
|
|
75
|
-
sa.DateTime(timezone=True),
|
|
76
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
77
|
-
),
|
|
78
|
-
sa.Column(
|
|
79
|
-
"updated_at",
|
|
80
|
-
sa.DateTime(timezone=True),
|
|
81
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
82
|
-
),
|
|
83
|
-
sa.PrimaryKeyConstraint("id", name="provider_configs_pkey"),
|
|
84
|
-
sa.ForeignKeyConstraint(
|
|
85
|
-
["tenant_id"],
|
|
86
|
-
[f"{SCHEMA}.tenants.id"],
|
|
87
|
-
ondelete="CASCADE",
|
|
88
|
-
name="provider_configs_tenant_id_fkey",
|
|
89
|
-
),
|
|
90
|
-
sa.UniqueConstraint(
|
|
91
|
-
"tenant_id",
|
|
92
|
-
"provider_name",
|
|
93
|
-
name="provider_configs_tenant_id_provider_name_key",
|
|
94
|
-
),
|
|
95
|
-
schema=SCHEMA,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
# users
|
|
99
|
-
op.create_table(
|
|
100
|
-
"users",
|
|
101
|
-
sa.Column(
|
|
102
|
-
"id",
|
|
103
|
-
postgresql.UUID(as_uuid=False),
|
|
104
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
105
|
-
),
|
|
106
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
107
|
-
sa.Column("auth_provider", sa.String(length=50), nullable=False),
|
|
108
|
-
sa.Column("auth_subject", sa.String(length=255), nullable=False),
|
|
109
|
-
sa.Column("email", sa.String(length=255)),
|
|
110
|
-
sa.Column("display_name", sa.String(length=255)),
|
|
111
|
-
sa.Column("avatar_url", sa.Text()),
|
|
112
|
-
sa.Column(
|
|
113
|
-
"metadata",
|
|
114
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
115
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
116
|
-
),
|
|
117
|
-
sa.Column(
|
|
118
|
-
"created_at",
|
|
119
|
-
sa.DateTime(timezone=True),
|
|
120
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
121
|
-
),
|
|
122
|
-
sa.Column(
|
|
123
|
-
"updated_at",
|
|
124
|
-
sa.DateTime(timezone=True),
|
|
125
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
126
|
-
),
|
|
127
|
-
sa.PrimaryKeyConstraint("id", name="users_pkey"),
|
|
128
|
-
sa.ForeignKeyConstraint(
|
|
129
|
-
["tenant_id"],
|
|
130
|
-
[f"{SCHEMA}.tenants.id"],
|
|
131
|
-
ondelete="CASCADE",
|
|
132
|
-
name="users_tenant_id_fkey",
|
|
133
|
-
),
|
|
134
|
-
sa.UniqueConstraint(
|
|
135
|
-
"tenant_id",
|
|
136
|
-
"auth_provider",
|
|
137
|
-
"auth_subject",
|
|
138
|
-
name="users_tenant_id_auth_provider_auth_subject_key",
|
|
139
|
-
),
|
|
140
|
-
schema=SCHEMA,
|
|
141
|
-
)
|
|
142
|
-
op.create_index(
|
|
143
|
-
"idx_users_auth",
|
|
144
|
-
"users",
|
|
145
|
-
["auth_provider", "auth_subject"],
|
|
146
|
-
unique=False,
|
|
147
|
-
schema=SCHEMA,
|
|
148
|
-
)
|
|
149
|
-
op.create_index("idx_users_tenant", "users", ["tenant_id"], unique=False, schema=SCHEMA)
|
|
150
|
-
|
|
151
|
-
# boards
|
|
152
|
-
op.create_table(
|
|
153
|
-
"boards",
|
|
154
|
-
sa.Column(
|
|
155
|
-
"id",
|
|
156
|
-
postgresql.UUID(as_uuid=False),
|
|
157
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
158
|
-
),
|
|
159
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
160
|
-
sa.Column("owner_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
161
|
-
sa.Column("title", sa.String(length=255), nullable=False),
|
|
162
|
-
sa.Column("description", sa.Text()),
|
|
163
|
-
sa.Column("is_public", sa.Boolean(), server_default=sa.text("false")),
|
|
164
|
-
sa.Column(
|
|
165
|
-
"settings",
|
|
166
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
167
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
168
|
-
),
|
|
169
|
-
sa.Column(
|
|
170
|
-
"metadata",
|
|
171
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
172
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
173
|
-
),
|
|
174
|
-
sa.Column(
|
|
175
|
-
"created_at",
|
|
176
|
-
sa.DateTime(timezone=True),
|
|
177
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
178
|
-
),
|
|
179
|
-
sa.Column(
|
|
180
|
-
"updated_at",
|
|
181
|
-
sa.DateTime(timezone=True),
|
|
182
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
183
|
-
),
|
|
184
|
-
sa.PrimaryKeyConstraint("id", name="boards_pkey"),
|
|
185
|
-
sa.ForeignKeyConstraint(
|
|
186
|
-
["owner_id"],
|
|
187
|
-
[f"{SCHEMA}.users.id"],
|
|
188
|
-
ondelete="CASCADE",
|
|
189
|
-
name="boards_owner_id_fkey",
|
|
190
|
-
),
|
|
191
|
-
sa.ForeignKeyConstraint(
|
|
192
|
-
["tenant_id"],
|
|
193
|
-
[f"{SCHEMA}.tenants.id"],
|
|
194
|
-
ondelete="CASCADE",
|
|
195
|
-
name="boards_tenant_id_fkey",
|
|
196
|
-
),
|
|
197
|
-
schema=SCHEMA,
|
|
198
|
-
)
|
|
199
|
-
op.create_index("idx_boards_owner", "boards", ["owner_id"], unique=False, schema=SCHEMA)
|
|
200
|
-
op.create_index("idx_boards_tenant", "boards", ["tenant_id"], unique=False, schema=SCHEMA)
|
|
201
|
-
|
|
202
|
-
# lora_models
|
|
203
|
-
op.create_table(
|
|
204
|
-
"lora_models",
|
|
205
|
-
sa.Column(
|
|
206
|
-
"id",
|
|
207
|
-
postgresql.UUID(as_uuid=False),
|
|
208
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
209
|
-
),
|
|
210
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
211
|
-
sa.Column("user_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
212
|
-
sa.Column("name", sa.String(length=255), nullable=False),
|
|
213
|
-
sa.Column("base_model", sa.String(length=100), nullable=False),
|
|
214
|
-
sa.Column("storage_url", sa.Text(), nullable=False),
|
|
215
|
-
sa.Column("config", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
|
216
|
-
sa.Column("trigger_word", sa.String(length=100)),
|
|
217
|
-
sa.Column(
|
|
218
|
-
"metadata",
|
|
219
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
220
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
221
|
-
),
|
|
222
|
-
sa.Column("is_public", sa.Boolean(), server_default=sa.text("false")),
|
|
223
|
-
sa.Column(
|
|
224
|
-
"created_at",
|
|
225
|
-
sa.DateTime(timezone=True),
|
|
226
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
227
|
-
),
|
|
228
|
-
sa.Column(
|
|
229
|
-
"updated_at",
|
|
230
|
-
sa.DateTime(timezone=True),
|
|
231
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
232
|
-
),
|
|
233
|
-
sa.PrimaryKeyConstraint("id", name="lora_models_pkey"),
|
|
234
|
-
sa.ForeignKeyConstraint(
|
|
235
|
-
["tenant_id"],
|
|
236
|
-
[f"{SCHEMA}.tenants.id"],
|
|
237
|
-
ondelete="CASCADE",
|
|
238
|
-
name="lora_models_tenant_id_fkey",
|
|
239
|
-
),
|
|
240
|
-
sa.ForeignKeyConstraint(
|
|
241
|
-
["user_id"],
|
|
242
|
-
[f"{SCHEMA}.users.id"],
|
|
243
|
-
ondelete="CASCADE",
|
|
244
|
-
name="lora_models_user_id_fkey",
|
|
245
|
-
),
|
|
246
|
-
schema=SCHEMA,
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
# board_members
|
|
250
|
-
op.create_table(
|
|
251
|
-
"board_members",
|
|
252
|
-
sa.Column(
|
|
253
|
-
"id",
|
|
254
|
-
postgresql.UUID(as_uuid=False),
|
|
255
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
256
|
-
),
|
|
257
|
-
sa.Column("board_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
258
|
-
sa.Column("user_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
259
|
-
sa.Column("role", sa.String(length=20), nullable=False),
|
|
260
|
-
sa.Column("invited_by", postgresql.UUID(as_uuid=False)),
|
|
261
|
-
sa.Column(
|
|
262
|
-
"joined_at",
|
|
263
|
-
sa.DateTime(timezone=True),
|
|
264
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
265
|
-
),
|
|
266
|
-
sa.PrimaryKeyConstraint("id", name="board_members_pkey"),
|
|
267
|
-
sa.UniqueConstraint(
|
|
268
|
-
"board_id", "user_id", name="board_members_board_id_user_id_key"
|
|
269
|
-
),
|
|
270
|
-
sa.CheckConstraint(
|
|
271
|
-
"role::text = ANY (ARRAY['viewer'::character varying, "
|
|
272
|
-
"'editor'::character varying, 'admin'::character varying]::text[])",
|
|
273
|
-
name="board_members_role_check",
|
|
274
|
-
),
|
|
275
|
-
sa.ForeignKeyConstraint(
|
|
276
|
-
["board_id"],
|
|
277
|
-
[f"{SCHEMA}.boards.id"],
|
|
278
|
-
ondelete="CASCADE",
|
|
279
|
-
name="board_members_board_id_fkey",
|
|
280
|
-
),
|
|
281
|
-
sa.ForeignKeyConstraint(
|
|
282
|
-
["invited_by"],
|
|
283
|
-
[f"{SCHEMA}.users.id"],
|
|
284
|
-
name="board_members_invited_by_fkey",
|
|
285
|
-
),
|
|
286
|
-
sa.ForeignKeyConstraint(
|
|
287
|
-
["user_id"],
|
|
288
|
-
[f"{SCHEMA}.users.id"],
|
|
289
|
-
ondelete="CASCADE",
|
|
290
|
-
name="board_members_user_id_fkey",
|
|
291
|
-
),
|
|
292
|
-
schema=SCHEMA,
|
|
293
|
-
)
|
|
294
|
-
op.create_index(
|
|
295
|
-
"idx_board_members_board",
|
|
296
|
-
"board_members",
|
|
297
|
-
["board_id"],
|
|
298
|
-
unique=False,
|
|
299
|
-
schema=SCHEMA,
|
|
300
|
-
)
|
|
301
|
-
op.create_index(
|
|
302
|
-
"idx_board_members_user",
|
|
303
|
-
"board_members",
|
|
304
|
-
["user_id"],
|
|
305
|
-
unique=False,
|
|
306
|
-
schema=SCHEMA,
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
# generations
|
|
310
|
-
op.create_table(
|
|
311
|
-
"generations",
|
|
312
|
-
sa.Column(
|
|
313
|
-
"id",
|
|
314
|
-
postgresql.UUID(as_uuid=False),
|
|
315
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
316
|
-
),
|
|
317
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
318
|
-
sa.Column("board_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
319
|
-
sa.Column("user_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
320
|
-
sa.Column("generator_name", sa.String(length=100), nullable=False),
|
|
321
|
-
sa.Column("provider_name", sa.String(length=100), nullable=False),
|
|
322
|
-
sa.Column("artifact_type", sa.String(length=50), nullable=False),
|
|
323
|
-
sa.Column(
|
|
324
|
-
"input_params", postgresql.JSONB(astext_type=sa.Text()), nullable=False
|
|
325
|
-
),
|
|
326
|
-
sa.Column(
|
|
327
|
-
"status",
|
|
328
|
-
sa.String(length=50),
|
|
329
|
-
nullable=False,
|
|
330
|
-
server_default=sa.text("'pending'::character varying"),
|
|
331
|
-
),
|
|
332
|
-
sa.Column("storage_url", sa.Text()),
|
|
333
|
-
sa.Column("thumbnail_url", sa.Text()),
|
|
334
|
-
sa.Column(
|
|
335
|
-
"additional_files",
|
|
336
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
337
|
-
server_default=sa.text("'[]'::jsonb"),
|
|
338
|
-
),
|
|
339
|
-
sa.Column(
|
|
340
|
-
"output_metadata",
|
|
341
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
342
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
343
|
-
),
|
|
344
|
-
sa.Column("parent_generation_id", postgresql.UUID(as_uuid=False)),
|
|
345
|
-
sa.Column(
|
|
346
|
-
"input_generation_ids",
|
|
347
|
-
postgresql.ARRAY(postgresql.UUID()),
|
|
348
|
-
server_default=sa.text("'{}'::uuid[]"),
|
|
349
|
-
),
|
|
350
|
-
sa.Column("external_job_id", sa.String(length=255)),
|
|
351
|
-
sa.Column("progress", sa.Numeric(5, 2), server_default=sa.text("0.0")),
|
|
352
|
-
sa.Column("error_message", sa.Text()),
|
|
353
|
-
sa.Column("started_at", sa.DateTime(timezone=True)),
|
|
354
|
-
sa.Column("completed_at", sa.DateTime(timezone=True)),
|
|
355
|
-
sa.Column(
|
|
356
|
-
"created_at",
|
|
357
|
-
sa.DateTime(timezone=True),
|
|
358
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
359
|
-
),
|
|
360
|
-
sa.Column(
|
|
361
|
-
"updated_at",
|
|
362
|
-
sa.DateTime(timezone=True),
|
|
363
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
364
|
-
),
|
|
365
|
-
sa.PrimaryKeyConstraint("id", name="generations_pkey"),
|
|
366
|
-
sa.ForeignKeyConstraint(
|
|
367
|
-
["board_id"],
|
|
368
|
-
[f"{SCHEMA}.boards.id"],
|
|
369
|
-
ondelete="CASCADE",
|
|
370
|
-
name="generations_board_id_fkey",
|
|
371
|
-
),
|
|
372
|
-
sa.ForeignKeyConstraint(
|
|
373
|
-
["parent_generation_id"],
|
|
374
|
-
[f"{SCHEMA}.generations.id"],
|
|
375
|
-
name="generations_parent_generation_id_fkey",
|
|
376
|
-
),
|
|
377
|
-
sa.ForeignKeyConstraint(
|
|
378
|
-
["tenant_id"],
|
|
379
|
-
[f"{SCHEMA}.tenants.id"],
|
|
380
|
-
ondelete="CASCADE",
|
|
381
|
-
name="generations_tenant_id_fkey",
|
|
382
|
-
),
|
|
383
|
-
sa.ForeignKeyConstraint(
|
|
384
|
-
["user_id"],
|
|
385
|
-
[f"{SCHEMA}.users.id"],
|
|
386
|
-
ondelete="CASCADE",
|
|
387
|
-
name="generations_user_id_fkey",
|
|
388
|
-
),
|
|
389
|
-
schema=SCHEMA,
|
|
390
|
-
)
|
|
391
|
-
op.create_index(
|
|
392
|
-
"idx_generations_board", "generations", ["board_id"], unique=False, schema=SCHEMA
|
|
393
|
-
)
|
|
394
|
-
op.create_index(
|
|
395
|
-
"idx_generations_lineage",
|
|
396
|
-
"generations",
|
|
397
|
-
["parent_generation_id"],
|
|
398
|
-
unique=False,
|
|
399
|
-
schema=SCHEMA,
|
|
400
|
-
)
|
|
401
|
-
op.create_index(
|
|
402
|
-
"idx_generations_status", "generations", ["status"], unique=False, schema=SCHEMA
|
|
403
|
-
)
|
|
404
|
-
op.create_index(
|
|
405
|
-
"idx_generations_tenant", "generations", ["tenant_id"], unique=False, schema=SCHEMA
|
|
406
|
-
)
|
|
407
|
-
op.create_index(
|
|
408
|
-
"idx_generations_user", "generations", ["user_id"], unique=False, schema=SCHEMA
|
|
409
|
-
)
|
|
410
|
-
|
|
411
|
-
# credit_transactions
|
|
412
|
-
op.create_table(
|
|
413
|
-
"credit_transactions",
|
|
414
|
-
sa.Column(
|
|
415
|
-
"id",
|
|
416
|
-
postgresql.UUID(as_uuid=False),
|
|
417
|
-
server_default=sa.text("uuid_generate_v4()"),
|
|
418
|
-
),
|
|
419
|
-
sa.Column("tenant_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
420
|
-
sa.Column("user_id", postgresql.UUID(as_uuid=False), nullable=False),
|
|
421
|
-
sa.Column("transaction_type", sa.String(length=20), nullable=False),
|
|
422
|
-
sa.Column("amount", sa.Numeric(10, 4), nullable=False),
|
|
423
|
-
sa.Column("balance_after", sa.Numeric(10, 4), nullable=False),
|
|
424
|
-
sa.Column("generation_id", postgresql.UUID(as_uuid=False)),
|
|
425
|
-
sa.Column("description", sa.Text()),
|
|
426
|
-
sa.Column(
|
|
427
|
-
"metadata",
|
|
428
|
-
postgresql.JSONB(astext_type=sa.Text()),
|
|
429
|
-
server_default=sa.text("'{}'::jsonb"),
|
|
430
|
-
),
|
|
431
|
-
sa.Column(
|
|
432
|
-
"created_at",
|
|
433
|
-
sa.DateTime(timezone=True),
|
|
434
|
-
server_default=sa.text("CURRENT_TIMESTAMP"),
|
|
435
|
-
),
|
|
436
|
-
sa.PrimaryKeyConstraint("id", name="credit_transactions_pkey"),
|
|
437
|
-
sa.ForeignKeyConstraint(
|
|
438
|
-
["generation_id"],
|
|
439
|
-
[f"{SCHEMA}.generations.id"],
|
|
440
|
-
name="credit_transactions_generation_id_fkey",
|
|
441
|
-
),
|
|
442
|
-
sa.ForeignKeyConstraint(
|
|
443
|
-
["tenant_id"],
|
|
444
|
-
[f"{SCHEMA}.tenants.id"],
|
|
445
|
-
ondelete="CASCADE",
|
|
446
|
-
name="credit_transactions_tenant_id_fkey",
|
|
447
|
-
),
|
|
448
|
-
sa.ForeignKeyConstraint(
|
|
449
|
-
["user_id"],
|
|
450
|
-
[f"{SCHEMA}.users.id"],
|
|
451
|
-
ondelete="CASCADE",
|
|
452
|
-
name="credit_transactions_user_id_fkey",
|
|
453
|
-
),
|
|
454
|
-
sa.CheckConstraint(
|
|
455
|
-
"transaction_type::text = ANY (ARRAY["
|
|
456
|
-
"'reserve'::character varying, 'finalize'::character varying, "
|
|
457
|
-
"'refund'::character varying, 'purchase'::character varying, "
|
|
458
|
-
"'grant'::character varying]::text[])",
|
|
459
|
-
name="credit_transactions_transaction_type_check",
|
|
460
|
-
),
|
|
461
|
-
schema=SCHEMA,
|
|
462
|
-
)
|
|
463
|
-
op.create_index(
|
|
464
|
-
"idx_credit_transactions_user",
|
|
465
|
-
"credit_transactions",
|
|
466
|
-
["user_id"],
|
|
467
|
-
unique=False,
|
|
468
|
-
schema=SCHEMA,
|
|
469
|
-
)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
def downgrade() -> None:
|
|
473
|
-
# drop in reverse dependency order
|
|
474
|
-
op.drop_index(
|
|
475
|
-
"idx_credit_transactions_user", table_name="credit_transactions", schema=SCHEMA
|
|
476
|
-
)
|
|
477
|
-
op.drop_table("credit_transactions", schema=SCHEMA)
|
|
478
|
-
|
|
479
|
-
op.drop_index("idx_generations_user", table_name="generations", schema=SCHEMA)
|
|
480
|
-
op.drop_index("idx_generations_tenant", table_name="generations", schema=SCHEMA)
|
|
481
|
-
op.drop_index("idx_generations_status", table_name="generations", schema=SCHEMA)
|
|
482
|
-
op.drop_index("idx_generations_lineage", table_name="generations", schema=SCHEMA)
|
|
483
|
-
op.drop_index("idx_generations_board", table_name="generations", schema=SCHEMA)
|
|
484
|
-
op.drop_table("generations", schema=SCHEMA)
|
|
485
|
-
|
|
486
|
-
op.drop_index("idx_board_members_user", table_name="board_members", schema=SCHEMA)
|
|
487
|
-
op.drop_index("idx_board_members_board", table_name="board_members", schema=SCHEMA)
|
|
488
|
-
op.drop_table("board_members", schema=SCHEMA)
|
|
489
|
-
|
|
490
|
-
op.drop_table("lora_models", schema=SCHEMA)
|
|
491
|
-
|
|
492
|
-
op.drop_index("idx_boards_tenant", table_name="boards", schema=SCHEMA)
|
|
493
|
-
op.drop_index("idx_boards_owner", table_name="boards", schema=SCHEMA)
|
|
494
|
-
op.drop_table("boards", schema=SCHEMA)
|
|
495
|
-
|
|
496
|
-
op.drop_index("idx_users_tenant", table_name="users", schema=SCHEMA)
|
|
497
|
-
op.drop_index("idx_users_auth", table_name="users", schema=SCHEMA)
|
|
498
|
-
op.drop_table("users", schema=SCHEMA)
|
|
499
|
-
|
|
500
|
-
op.drop_table("provider_configs", schema=SCHEMA)
|
|
501
|
-
|
|
502
|
-
op.drop_table("tenants", schema=SCHEMA)
|
|
503
|
-
|
|
504
|
-
# Drop the schema with CASCADE to remove alembic_version table too
|
|
505
|
-
# Will fail if non-Boards objects exist (beyond alembic_version), which is intentional
|
|
506
|
-
op.execute(f"DROP SCHEMA IF EXISTS {SCHEMA} CASCADE;")
|