mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-03-23 19:27:51 -04:00
- Added 'identifier' column (unique) for machine-readable plugin ID - 'name' now used for display name only - Updated trial-execution to look up by identifier first, then name - Added migration script for existing databases
32 lines
932 B
TypeScript
32 lines
932 B
TypeScript
import { db } from "~/server/db";
|
|
import { sql } from "drizzle-orm";
|
|
|
|
async function migrate() {
|
|
console.log("Adding identifier column to hs_plugin...");
|
|
|
|
try {
|
|
await db.execute(sql`ALTER TABLE hs_plugin ADD COLUMN identifier varchar(100)`);
|
|
console.log("✓ Added identifier column");
|
|
} catch (e: any) {
|
|
console.log("Column may already exist:", e.message);
|
|
}
|
|
|
|
try {
|
|
await db.execute(sql`UPDATE hs_plugin SET identifier = name WHERE identifier IS NULL`);
|
|
console.log("✓ Copied name to identifier");
|
|
} catch (e: any) {
|
|
console.log("Error copying:", e.message);
|
|
}
|
|
|
|
try {
|
|
await db.execute(sql`ALTER TABLE hs_plugin ADD CONSTRAINT hs_plugin_identifier_unique UNIQUE (identifier)`);
|
|
console.log("✓ Added unique constraint");
|
|
} catch (e: any) {
|
|
console.log("Constraint may already exist:", e.message);
|
|
}
|
|
|
|
console.log("Migration complete!");
|
|
}
|
|
|
|
migrate().catch(console.error);
|