Skip to content
Merged
15 changes: 15 additions & 0 deletions migrations/1774658921003_user_role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { type Kysely, sql } from "kysely";

// `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface.
export async function up(db: Kysely<any>): Promise<void> {
await db.schema.alterTable("user").addColumn("role", "text").execute();
await sql`UPDATE "user" SET role = 'Superadmin' WHERE email = 'hello@commonknowledge.coop'`.execute(
db,
);
}

// `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface.
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.alterTable("user").dropColumn("role").execute();
}
29 changes: 29 additions & 0 deletions migrations/1774658921004_data_source_config_org_unique.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Kysely } from "kysely";

// `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface.
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.alterTable("dataSource")
.dropConstraint("data_source_config_key")
.execute();
Comment thread
joaquimds marked this conversation as resolved.
await db.schema
.alterTable("dataSource")
.addUniqueConstraint("data_source_config_organisation_id_key", [
"config",
"organisationId",
])
.execute();
}

// `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface.
export async function down(db: Kysely<any>): Promise<void> {
await db.schema
.alterTable("dataSource")
.dropConstraint("data_source_config_organisation_id_key")
.execute();
await db.schema
.alterTable("dataSource")
.addUniqueConstraint("data_source_config_key", ["config"])
.execute();
}
1 change: 1 addition & 0 deletions modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ declare module "mapbox-gl/dist/style-spec/index.cjs" {
export * from "mapbox-gl/dist/style-spec/index.d.ts";
}
declare module "pg-cursor";
declare module "*.css";
Loading
Loading