Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
openint-bot committed Feb 27, 2025
1 parent 580833a commit 7753937
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages-v1/db-v1/db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ beforeAll(async () => {
})

describe.each(Object.keys(dbs))('drizzle: %s', (key) => {
const db = dbs[key as keyof typeof dbs]

test('select', async () => {
const db = dbs[key as keyof typeof dbs]
const res = await db.execute(sql`SELECT 1 + 1 AS result`)
const rows = 'rows' in res ? res.rows : res
expect(rows[0]).toEqual({result: 2})
})

test('migration then use migrated tables', async () => {
const db = dbs[key as keyof typeof dbs]
await bootstrap(db)
const returning = await db
.insert(schema.organization)
Expand All @@ -72,6 +72,6 @@ describe.each(Object.keys(dbs))('drizzle: %s', (key) => {
})

afterAll(async () => {
await dbs.pglite.$client.close()
// await dbs.pglite.$client.close()
await dbs.postgres.$client.end()
})
41 changes: 41 additions & 0 deletions packages-v1/db-v1/migrations/0000_initial.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
CREATE TABLE "connection" (
"id" varchar PRIMARY KEY NOT NULL,
"connector_config_id" varchar NOT NULL,
"connector_name" varchar GENERATED ALWAYS AS (nullif(split_part(connector_config_id, '_', 2), '')) STORED NOT NULL,
"settings" jsonb,
"integration_id" varchar NOT NULL,
"customer_id" varchar NOT NULL,
"remote_data" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "connector_config" (
"id" varchar PRIMARY KEY NOT NULL,
"org_id" varchar NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"connector_name" varchar GENERATED ALWAYS AS (nullif(split_part(id, '_', 2), '')) STORED NOT NULL,
"config" jsonb
);
--> statement-breakpoint
CREATE TABLE "integration" (
"id" varchar PRIMARY KEY NOT NULL,
"connector_config_id" varchar NOT NULL,
"connector_name" varchar GENERATED ALWAYS AS (nullif(split_part(connector_config_id, '_', 2), '')) STORED NOT NULL,
"name" varchar NOT NULL,
"logo_url" varchar,
"remote_data" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "organization" (
"id" varchar PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"api_key" varchar NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE INDEX "connector_config_org_id_index" ON "connector_config" USING btree ("org_id");
275 changes: 275 additions & 0 deletions packages-v1/db-v1/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
{
"id": "6c3d4069-84de-4373-90f7-296b88976aaa",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.connection": {
"name": "connection",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"connector_config_id": {
"name": "connector_config_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"connector_name": {
"name": "connector_name",
"type": "varchar",
"primaryKey": false,
"notNull": true,
"generated": {
"as": "nullif(split_part(connector_config_id, '_', 2), '')",
"type": "stored"
}
},
"settings": {
"name": "settings",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"integration_id": {
"name": "integration_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"customer_id": {
"name": "customer_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"remote_data": {
"name": "remote_data",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.connector_config": {
"name": "connector_config",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"org_id": {
"name": "org_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"connector_name": {
"name": "connector_name",
"type": "varchar",
"primaryKey": false,
"notNull": true,
"generated": {
"as": "nullif(split_part(id, '_', 2), '')",
"type": "stored"
}
},
"config": {
"name": "config",
"type": "jsonb",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"connector_config_org_id_index": {
"name": "connector_config_org_id_index",
"columns": [
{
"expression": "org_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.integration": {
"name": "integration",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"connector_config_id": {
"name": "connector_config_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"connector_name": {
"name": "connector_name",
"type": "varchar",
"primaryKey": false,
"notNull": true,
"generated": {
"as": "nullif(split_part(connector_config_id, '_', 2), '')",
"type": "stored"
}
},
"name": {
"name": "name",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"logo_url": {
"name": "logo_url",
"type": "varchar",
"primaryKey": false,
"notNull": false
},
"remote_data": {
"name": "remote_data",
"type": "jsonb",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.organization": {
"name": "organization",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"api_key": {
"name": "api_key",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
13 changes: 13 additions & 0 deletions packages-v1/db-v1/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1740673930201,
"tag": "0000_initial",
"breakpoints": true
}
]
}
Loading

0 comments on commit 7753937

Please sign in to comment.