@powerhousedao/network-admin 0.0.33 → 0.0.34
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/workstreams/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGrE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/workstreams/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGrE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B9D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { sql } from "kysely";
|
|
2
1
|
export async function up(db) {
|
|
3
2
|
// Create table with IF NOT EXISTS
|
|
4
3
|
let tableCreated = false;
|
|
4
|
+
await down(db);
|
|
5
5
|
try {
|
|
6
6
|
await db.schema
|
|
7
7
|
.createTable("workstreams")
|
|
@@ -25,49 +25,6 @@ export async function up(db) {
|
|
|
25
25
|
// Table creation failed, might already exist or error occurred
|
|
26
26
|
// Check if table exists before trying to add columns
|
|
27
27
|
}
|
|
28
|
-
// Check if table exists before trying to add columns
|
|
29
|
-
let tableExists = false;
|
|
30
|
-
try {
|
|
31
|
-
const result = await sql `
|
|
32
|
-
SELECT EXISTS (
|
|
33
|
-
SELECT FROM information_schema.tables
|
|
34
|
-
WHERE table_name = 'workstreams'
|
|
35
|
-
)
|
|
36
|
-
`.execute(db);
|
|
37
|
-
tableExists = result.rows?.[0]?.exists === true || result[0]?.exists === true;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
// If we can't check, assume table doesn't exist
|
|
41
|
-
tableExists = false;
|
|
42
|
-
}
|
|
43
|
-
// Only try to add columns if table exists and wasn't just created
|
|
44
|
-
if (tableExists && !tableCreated) {
|
|
45
|
-
// Add missing columns if table already existed (migration upgrade path)
|
|
46
|
-
// Use try-catch since PostgreSQL doesn't support IF NOT EXISTS for ALTER TABLE ADD COLUMN
|
|
47
|
-
const addColumnIfNotExists = async (columnName, columnDef) => {
|
|
48
|
-
try {
|
|
49
|
-
await db.schema.alterTable("workstreams").addColumn(columnName, columnDef).execute();
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
// Column already exists (error code 42701) - ignore
|
|
53
|
-
// Table doesn't exist (error code 42P01) - ignore (shouldn't happen but handle gracefully)
|
|
54
|
-
if (error?.code !== '42701' && error?.code !== '42P16' && error?.code !== '42P01') {
|
|
55
|
-
console.warn(`Error adding column ${columnName}:`, error?.message || error);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
await addColumnIfNotExists('network_phid', 'varchar(255)');
|
|
60
|
-
await addColumnIfNotExists('network_slug', 'varchar(255)');
|
|
61
|
-
await addColumnIfNotExists('workstream_phid', 'varchar(255)');
|
|
62
|
-
await addColumnIfNotExists('workstream_slug', 'varchar(255)');
|
|
63
|
-
await addColumnIfNotExists('workstream_title', 'varchar(255)');
|
|
64
|
-
await addColumnIfNotExists('workstream_status', 'varchar(255)');
|
|
65
|
-
await addColumnIfNotExists('sow_phid', 'varchar(255)');
|
|
66
|
-
await addColumnIfNotExists('roadmap_oid', 'varchar(255)');
|
|
67
|
-
await addColumnIfNotExists('final_milestone_target', 'timestamp');
|
|
68
|
-
await addColumnIfNotExists('initial_proposal_status', 'varchar(255)');
|
|
69
|
-
await addColumnIfNotExists('initial_proposal_author', 'varchar(255)');
|
|
70
|
-
}
|
|
71
28
|
}
|
|
72
29
|
export async function down(db) {
|
|
73
30
|
// drop table
|