68 lines
2.1 KiB
Rust
68 lines
2.1 KiB
Rust
use anyhow::Result;
|
|
use dotenv::dotenv;
|
|
use momentry_core::core::config;
|
|
use momentry_core::core::db::PostgresDb;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
tracing_subscriber::fmt::init();
|
|
dotenv().ok();
|
|
|
|
let db = PostgresDb::new(&config::DATABASE_URL).await?;
|
|
|
|
println!("Creating scenes table...");
|
|
|
|
sqlx::query(
|
|
"CREATE TABLE IF NOT EXISTS scenes (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
file_uuid VARCHAR(32) NOT NULL,
|
|
scene_index INTEGER NOT NULL,
|
|
timestamp_sec DOUBLE PRECISION NOT NULL,
|
|
frame_number BIGINT NOT NULL,
|
|
filename VARCHAR(255) NOT NULL,
|
|
selection_reason VARCHAR(50),
|
|
quality_score DOUBLE PRECISION,
|
|
quality_source VARCHAR(100),
|
|
vlm_status VARCHAR(20) DEFAULT 'pending',
|
|
vlm_description TEXT,
|
|
vlm_scene_type VARCHAR(100),
|
|
vlm_location VARCHAR(255),
|
|
vlm_objects JSONB DEFAULT '[]',
|
|
vlm_tags JSONB DEFAULT '[]',
|
|
vlm_attributes JSONB,
|
|
face_count INTEGER DEFAULT 0,
|
|
person_traces JSONB DEFAULT '[]',
|
|
has_cut BOOLEAN DEFAULT false,
|
|
cut_count INTEGER DEFAULT 0,
|
|
scene_info JSONB,
|
|
embedding_status VARCHAR(20) DEFAULT 'pending',
|
|
embedding_point_id VARCHAR(64),
|
|
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
|
UNIQUE(file_uuid, scene_index)
|
|
)",
|
|
)
|
|
.execute(db.pool())
|
|
.await?;
|
|
|
|
sqlx::query("CREATE INDEX IF NOT EXISTS idx_scenes_file_uuid ON scenes(file_uuid)")
|
|
.execute(db.pool())
|
|
.await?;
|
|
|
|
sqlx::query("CREATE INDEX IF NOT EXISTS idx_scenes_tags ON scenes USING GIN(vlm_tags)")
|
|
.execute(db.pool())
|
|
.await?;
|
|
|
|
sqlx::query("CREATE INDEX IF NOT EXISTS idx_scenes_objects ON scenes USING GIN(vlm_objects)")
|
|
.execute(db.pool())
|
|
.await?;
|
|
|
|
sqlx::query("CREATE INDEX IF NOT EXISTS idx_scenes_timestamp ON scenes(timestamp_sec)")
|
|
.execute(db.pool())
|
|
.await?;
|
|
|
|
println!("✅ Scenes table created successfully");
|
|
|
|
Ok(())
|
|
}
|