streamby-core 0.21.3 → 0.21.5
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.
|
@@ -43,53 +43,55 @@ const getConnection = (id) => {
|
|
|
43
43
|
exports.getConnection = getConnection;
|
|
44
44
|
const ensureTablesExist = async (pool) => {
|
|
45
45
|
try {
|
|
46
|
-
await pool.query(`
|
|
47
|
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
48
|
-
CREATE TABLE IF NOT EXISTS projects (
|
|
49
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
50
|
-
name VARCHAR(255) NOT NULL,
|
|
51
|
-
description TEXT,
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
46
|
+
await pool.query(`
|
|
47
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
48
|
+
CREATE TABLE IF NOT EXISTS projects (
|
|
49
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
50
|
+
name VARCHAR(255) NOT NULL,
|
|
51
|
+
description TEXT,
|
|
52
|
+
image TEXT,
|
|
53
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
54
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
55
|
+
);
|
|
55
56
|
`);
|
|
56
57
|
console.log('✅ "projects" table ensured to exist.');
|
|
57
58
|
// Ensure dbType column exists and is correctly configured
|
|
58
|
-
await pool.query(`
|
|
59
|
-
ALTER TABLE projects ADD COLUMN IF NOT EXISTS "dbType" VARCHAR(50);
|
|
59
|
+
await pool.query(`
|
|
60
|
+
ALTER TABLE projects ADD COLUMN IF NOT EXISTS "dbType" VARCHAR(50);
|
|
60
61
|
`);
|
|
61
|
-
await pool.query(`
|
|
62
|
-
UPDATE projects SET "dbType" = 'nosql' WHERE "dbType" IS NULL;
|
|
62
|
+
await pool.query(`
|
|
63
|
+
UPDATE projects SET "dbType" = 'nosql' WHERE "dbType" IS NULL;
|
|
63
64
|
`);
|
|
64
|
-
await pool.query(`
|
|
65
|
-
ALTER TABLE projects ALTER COLUMN "dbType" SET NOT NULL;
|
|
65
|
+
await pool.query(`
|
|
66
|
+
ALTER TABLE projects ALTER COLUMN "dbType" SET NOT NULL;
|
|
66
67
|
`);
|
|
67
|
-
await pool.query(`
|
|
68
|
-
ALTER TABLE projects ALTER COLUMN "dbType" SET DEFAULT 'nosql';
|
|
68
|
+
await pool.query(`
|
|
69
|
+
ALTER TABLE projects ALTER COLUMN "dbType" SET DEFAULT 'nosql';
|
|
69
70
|
`);
|
|
70
|
-
await pool.query(`
|
|
71
|
-
CREATE TABLE IF NOT EXISTS exports (
|
|
72
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
73
|
-
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
74
|
-
status VARCHAR(50) NOT NULL DEFAULT 'pending',
|
|
75
|
-
"filePath" TEXT,
|
|
76
|
-
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
77
|
-
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
78
|
-
);
|
|
71
|
+
await pool.query(`
|
|
72
|
+
CREATE TABLE IF NOT EXISTS exports (
|
|
73
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
74
|
+
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
75
|
+
status VARCHAR(50) NOT NULL DEFAULT 'pending',
|
|
76
|
+
"filePath" TEXT,
|
|
77
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
78
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
79
|
+
);
|
|
79
80
|
`);
|
|
80
81
|
console.log('✅ "exports" table ensured to exist.');
|
|
81
|
-
await pool.query(`
|
|
82
|
-
CREATE TABLE IF NOT EXISTS project_members (
|
|
83
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
84
|
-
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
85
|
-
"userId" VARCHAR(255) NOT NULL,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
await pool.query(`
|
|
83
|
+
CREATE TABLE IF NOT EXISTS project_members (
|
|
84
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
85
|
+
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86
|
+
"userId" VARCHAR(255) NOT NULL,
|
|
87
|
+
role VARCHAR(255) NOT NULL DEFAULT 'member',
|
|
88
|
+
archived BOOLEAN NOT NULL DEFAULT FALSE,
|
|
89
|
+
"archivedBy" VARCHAR(255),
|
|
90
|
+
"archivedAt" TIMESTAMP WITH TIME ZONE,
|
|
91
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
92
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
93
|
+
UNIQUE ("projectId", "userId")
|
|
94
|
+
);
|
|
93
95
|
`);
|
|
94
96
|
console.log('✅ "project_members" table ensured to exist.');
|
|
95
97
|
}
|