@dungarees/datasource 0.11.4
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.
- package/fake.d.ts +35 -0
- package/fake.js +51 -0
- package/fake.test.d.ts +1 -0
- package/fake.test.js +558 -0
- package/helpers.d.ts +2 -0
- package/helpers.js +4 -0
- package/migration/inmemory-migrator.d.ts +2 -0
- package/migration/inmemory-migrator.js +126 -0
- package/migration/kysely-migrator.d.ts +2 -0
- package/migration/kysely-migrator.js +6 -0
- package/migration/migration.d.ts +4 -0
- package/migration/migration.js +5 -0
- package/migration/provider.d.ts +5 -0
- package/migration/provider.js +39 -0
- package/migration/service.d.ts +2 -0
- package/migration/service.js +24 -0
- package/migration/type.d.ts +48 -0
- package/migration/type.js +1 -0
- package/package.json +510 -0
- package/postgres/fake.d.ts +2 -0
- package/postgres/fake.js +45 -0
- package/postgres/service.d.ts +11 -0
- package/postgres/service.js +23 -0
- package/service.d.ts +2 -0
- package/service.js +1 -0
- package/service.test.d.ts +1 -0
- package/service.test.js +37 -0
- package/test-migrations/001-test-migration.d.ts +2 -0
- package/test-migrations/001-test-migration.js +13 -0
- package/test-migrations/002-test-migration.d.ts +2 -0
- package/test-migrations/002-test-migration.js +9 -0
- package/test-migrations/003-test-migration.d.ts +2 -0
- package/test-migrations/003-test-migration.js +9 -0
- package/test-migrations-with-error/001-test-migration.d.ts +2 -0
- package/test-migrations-with-error/001-test-migration.js +13 -0
- package/test-migrations-with-error/002-test-migration.d.ts +2 -0
- package/test-migrations-with-error/002-test-migration.js +10 -0
- package/type.d.ts +5 -0
- package/type.js +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createMigration } from '../migration/migration.js';
|
|
2
|
+
export default createMigration({
|
|
3
|
+
up: async (db) => {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createTable('table1')
|
|
6
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
+
.addColumn('name', 'varchar', (col) => col.notNull())
|
|
8
|
+
.execute();
|
|
9
|
+
},
|
|
10
|
+
down: async (db) => {
|
|
11
|
+
await db.schema.dropTable('table1').execute();
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createMigration } from '../migration/migration.js';
|
|
2
|
+
export default createMigration({
|
|
3
|
+
up: async (db) => {
|
|
4
|
+
await db.insertInto('table1').values({ name: 'test1' }).execute();
|
|
5
|
+
},
|
|
6
|
+
down: async (db) => {
|
|
7
|
+
await db.deleteFrom('table1').where('name', '=', 'test1').execute();
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createMigration } from '../migration/migration.js';
|
|
2
|
+
export default createMigration({
|
|
3
|
+
up: async (db) => {
|
|
4
|
+
await db.insertInto('table1').values({ name: 'test2' }).execute();
|
|
5
|
+
},
|
|
6
|
+
down: async (db) => {
|
|
7
|
+
await db.deleteFrom('table1').where('name', '=', 'test2').execute();
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createMigration } from '../migration/migration.js';
|
|
2
|
+
export default createMigration({
|
|
3
|
+
up: async (db) => {
|
|
4
|
+
await db.schema
|
|
5
|
+
.createTable('table1')
|
|
6
|
+
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
+
.addColumn('name', 'varchar', (col) => col.notNull())
|
|
8
|
+
.execute();
|
|
9
|
+
},
|
|
10
|
+
down: async (db) => {
|
|
11
|
+
await db.schema.dropTable('table1').execute();
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createMigration } from '../migration/migration.js';
|
|
2
|
+
// Writes to a column that does not exist, so the migrator has a real failure to report.
|
|
3
|
+
export default createMigration({
|
|
4
|
+
up: async (db) => {
|
|
5
|
+
await db.insertInto('table1').values({ name: 'test1', missingColumn: 'boom' }).execute();
|
|
6
|
+
},
|
|
7
|
+
down: async (db) => {
|
|
8
|
+
await db.deleteFrom('table1').where('name', '=', 'test1').execute();
|
|
9
|
+
},
|
|
10
|
+
});
|
package/type.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
export type { Generated, JSONColumnType, QueryResult, Transaction } from 'kysely';
|
|
3
|
+
export type Datasource<SCHEMA> = Kysely<SCHEMA>;
|
|
4
|
+
export type ConnectionBuilder = <SCHEMA>() => Datasource<SCHEMA>;
|
|
5
|
+
export type AnySchema = any;
|
package/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|