refactor(schema): mark sqlalchemy models as schema mainline

This commit is contained in:
Xiaoxia AI
2026-06-21 06:30:55 +08:00
parent e61dfc27f6
commit 4b4602a0fd
4 changed files with 102 additions and 63 deletions
+13 -62
View File
@@ -1,63 +1,14 @@
CREATE TABLE IF NOT EXISTS users (
id VARCHAR(255) PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
username VARCHAR(255),
display_name VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
email_verified BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Deprecated schema snapshot.
--
-- Runtime schema creation is currently owned by SQLAlchemy models in:
-- packages/adapters/sqlalchemy_impl/models.py
--
-- Do not apply this file to staging or production. It is retained only for
-- historical reference while the project migrates toward a proper Alembic flow.
-- Applying it would create columns such as assets.library_id/storage_key/mime_type
-- that conflict with the current runtime table shape.
CREATE TABLE IF NOT EXISTS workspaces (
id VARCHAR(255) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
owner_user_id VARCHAR(255) NOT NULL REFERENCES users(id),
subscription_plan VARCHAR(50) DEFAULT 'free',
subscription_status VARCHAR(50) DEFAULT 'active',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS projects (
id VARCHAR(255) PRIMARY KEY,
workspace_id VARCHAR(255) NOT NULL REFERENCES workspaces(id),
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS assets (
id VARCHAR(255) PRIMARY KEY,
workspace_id VARCHAR(255) NOT NULL,
project_id VARCHAR(255) NOT NULL,
library_id VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
storage_key VARCHAR(500) NOT NULL,
mime_type VARCHAR(100) NOT NULL,
file_size BIGINT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS generation_tasks (
id VARCHAR(255) PRIMARY KEY,
workspace_id VARCHAR(255) NOT NULL,
project_id VARCHAR(255) NOT NULL,
asset_library_id VARCHAR(255) NOT NULL,
status VARCHAR(50) NOT NULL DEFAULT 'pending',
progress FLOAT DEFAULT 0,
result_count INTEGER DEFAULT 0,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS generated_videos (
id VARCHAR(255) PRIMARY KEY,
workspace_id VARCHAR(255) NOT NULL,
project_id VARCHAR(255) NOT NULL,
generation_task_id VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
file_url VARCHAR(500) NOT NULL,
file_size BIGINT,
duration FLOAT,
width INTEGER,
height INTEGER,
fps FLOAT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
DO $$
BEGIN
RAISE EXCEPTION 'init-tables.sql is deprecated. Use SQLAlchemy runtime schema initialization / future Alembic migrations instead.';
END $$;