rake-db 2.3.30 → 2.3.31

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.
Files changed (52) hide show
  1. package/package.json +11 -21
  2. package/.env +0 -1
  3. package/.env.local +0 -2
  4. package/.turbo/turbo-check.log +0 -23
  5. package/.turbo/turbo-test.log +0 -22
  6. package/.turbo/turbo-test:ci.log +0 -22
  7. package/CHANGELOG.md +0 -395
  8. package/app/dbScript.ts +0 -33
  9. package/app/migrations/20221017181504_createUser.ts +0 -14
  10. package/app/migrations/20221017200111_createProfile.ts +0 -10
  11. package/app/migrations/20221017200252_createChat.ts +0 -9
  12. package/app/migrations/20221017200326_createChatUser.ts +0 -10
  13. package/app/migrations/20221017200900_createMessage.ts +0 -12
  14. package/app/migrations/20221017201235_createGeoSchema.ts +0 -5
  15. package/app/migrations/20221017210011_createCountry.ts +0 -8
  16. package/app/migrations/20221017210133_createCity.ts +0 -9
  17. package/app/migrations/20221105202843_createUniqueTable.ts +0 -12
  18. package/jest-setup.ts +0 -3
  19. package/rollup.config.js +0 -3
  20. package/src/ast.ts +0 -130
  21. package/src/commands/createOrDrop.test.ts +0 -214
  22. package/src/commands/createOrDrop.ts +0 -151
  23. package/src/commands/generate.test.ts +0 -136
  24. package/src/commands/generate.ts +0 -93
  25. package/src/commands/migrateOrRollback.test.ts +0 -267
  26. package/src/commands/migrateOrRollback.ts +0 -190
  27. package/src/common.test.ts +0 -295
  28. package/src/common.ts +0 -353
  29. package/src/errors.ts +0 -3
  30. package/src/index.ts +0 -8
  31. package/src/migration/change.test.ts +0 -16
  32. package/src/migration/change.ts +0 -15
  33. package/src/migration/changeTable.test.ts +0 -897
  34. package/src/migration/changeTable.ts +0 -566
  35. package/src/migration/createTable.test.ts +0 -384
  36. package/src/migration/createTable.ts +0 -193
  37. package/src/migration/migration.test.ts +0 -430
  38. package/src/migration/migration.ts +0 -518
  39. package/src/migration/migrationUtils.ts +0 -307
  40. package/src/migration/tableMethods.ts +0 -8
  41. package/src/pull/astToMigration.test.ts +0 -275
  42. package/src/pull/astToMigration.ts +0 -173
  43. package/src/pull/dbStructure.test.ts +0 -180
  44. package/src/pull/dbStructure.ts +0 -413
  45. package/src/pull/pull.test.ts +0 -115
  46. package/src/pull/pull.ts +0 -22
  47. package/src/pull/structureToAst.test.ts +0 -841
  48. package/src/pull/structureToAst.ts +0 -372
  49. package/src/rakeDb.test.ts +0 -131
  50. package/src/rakeDb.ts +0 -84
  51. package/src/test-utils.ts +0 -64
  52. package/tsconfig.json +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rake-db",
3
- "version": "2.3.30",
3
+ "version": "2.3.31",
4
4
  "description": "Migrations tool for Postgresql DB",
5
5
  "homepage": "https://orchid-orm.netlify.app/guide/migration-setup-and-overview.html",
6
6
  "repository": {
@@ -17,14 +17,18 @@
17
17
  "types": "./dist/index.d.ts"
18
18
  }
19
19
  },
20
+ "files": [
21
+ "dist"
22
+ ],
20
23
  "jest": {
24
+ "rootDir": "src",
21
25
  "setupFiles": [
22
26
  "dotenv/config"
23
27
  ],
24
- "globalSetup": "../../jest-global-setup.ts",
28
+ "globalSetup": "../../../jest-global-setup.ts",
25
29
  "setupFilesAfterEnv": [
26
- "../../jest-setup.ts",
27
- "./jest-setup.ts"
30
+ "../../../jest-setup.ts",
31
+ "../jest-setup.ts"
28
32
  ],
29
33
  "transform": {
30
34
  "^.+\\.ts$": "@swc/jest"
@@ -41,32 +45,18 @@
41
45
  "license": "ISC",
42
46
  "dependencies": {
43
47
  "pluralize": "^8.0.0",
44
- "pqb": "0.9.17",
48
+ "pqb": "0.9.18",
45
49
  "prompts": "^2.4.2"
46
50
  },
47
51
  "devDependencies": {
48
- "@swc/core": "^1.2.210",
49
- "@swc/helpers": "^0.4.12",
50
- "@swc/jest": "^0.2.21",
51
- "@types/jest": "^28.1.2",
52
- "@types/node": "^18.0.1",
53
- "@types/pluralize": "^0.0.29",
54
52
  "@types/prompts": "^2.4.2",
55
- "dotenv": "^16.0.3",
56
- "jest": "^28.1.2",
57
- "rimraf": "^3.0.2",
58
- "rollup": "^2.79.0",
59
- "rollup-plugin-dts": "^4.2.2",
60
- "rollup-plugin-esbuild": "^4.10.1",
61
- "ts-node": "^10.9.1",
62
- "tsconfig-paths": "^4.1.0",
63
- "tslib": "^2.4.0",
64
- "typescript": "^4.7.4"
53
+ "tsconfig-paths": "^4.1.2"
65
54
  },
66
55
  "scripts": {
67
56
  "db": "ts-node -r tsconfig-paths/register app/dbScript.ts",
68
57
  "test": "jest --watch --verbose false",
69
58
  "check": "jest",
59
+ "types": "tsc",
70
60
  "test:ci": "jest --coverage --coverageReporters json-summary",
71
61
  "build": "rimraf ./dist/ && rollup -c --rollup.config"
72
62
  }
package/.env DELETED
@@ -1 +0,0 @@
1
- DATABASE_URL=postgres://postgres:@localhost:5432/orchid-orm
package/.env.local DELETED
@@ -1,2 +0,0 @@
1
- DATABASE_URL=postgres://postgres:@localhost:5432/porm
2
- #DATABASE_URL=postgres://romeerez:e2Y6ovIJruas@ep-autumn-tooth-279704.eu-central-1.aws.neon.tech/neondb?ssl=true
@@ -1,23 +0,0 @@
1
-
2
- > rake-db@2.3.29 check /home/romeo/dev/my/orchid-orm/packages/rake-db
3
- > jest
4
-
5
- PASS src/migration/changeTable.test.ts
6
- PASS src/pull/structureToAst.test.ts
7
- PASS src/migration/createTable.test.ts
8
- PASS src/commands/migrateOrRollback.test.ts
9
- PASS src/common.test.ts
10
- PASS src/commands/generate.test.ts
11
- PASS src/rakeDb.test.ts
12
- PASS src/migration/migration.test.ts
13
- PASS src/pull/astToMigration.test.ts
14
- PASS src/commands/createOrDrop.test.ts
15
- PASS src/pull/dbStructure.test.ts
16
- PASS src/pull/pull.test.ts
17
- PASS src/migration/change.test.ts
18
-
19
- Test Suites: 13 passed, 13 total
20
- Tests: 207 passed, 207 total
21
- Snapshots: 0 total
22
- Time: 10.891 s
23
- Ran all test suites.
@@ -1,22 +0,0 @@
1
-
2
- > rake-db@2.3.22 test /home/romeo/dev/my/orchid-orm/packages/rake-db
3
- > jest "--coverage" "--coverageReporters" "json-summary"
4
-
5
- PASS src/migration/migration.test.ts
6
- PASS src/commands/createOrDrop.test.ts
7
- PASS src/commands/migrateOrRollback.test.ts
8
- PASS src/migration/changeTable.test.ts
9
- PASS src/common.test.ts
10
- PASS src/pull/dbStructure.test.ts
11
- PASS src/rakeDb.test.ts
12
- PASS src/pull/structureToAst.test.ts
13
- PASS src/commands/generate.test.ts
14
- PASS src/pull/astToMigration.test.ts
15
- PASS src/migration/createTable.test.ts
16
- PASS src/pull/pull.test.ts
17
-
18
- Test Suites: 12 passed, 12 total
19
- Tests: 182 passed, 182 total
20
- Snapshots: 0 total
21
- Time: 3.951 s
22
- Ran all test suites.
@@ -1,22 +0,0 @@
1
-
2
- > rake-db@2.3.24 test:ci /home/romeo/dev/my/orchid-orm/packages/rake-db
3
- > jest --coverage --coverageReporters json-summary
4
-
5
- PASS src/commands/createOrDrop.test.ts
6
- PASS src/common.test.ts
7
- PASS src/migration/changeTable.test.ts
8
- PASS src/pull/structureToAst.test.ts
9
- PASS src/commands/migrateOrRollback.test.ts
10
- PASS src/migration/migration.test.ts
11
- PASS src/migration/createTable.test.ts
12
- PASS src/pull/astToMigration.test.ts
13
- PASS src/commands/generate.test.ts
14
- PASS src/pull/pull.test.ts
15
- PASS src/rakeDb.test.ts
16
- PASS src/pull/dbStructure.test.ts
17
-
18
- Test Suites: 12 passed, 12 total
19
- Tests: 184 passed, 184 total
20
- Snapshots: 0 total
21
- Time: 6.736 s
22
- Ran all test suites.
package/CHANGELOG.md DELETED
@@ -1,395 +0,0 @@
1
- # rake-db
2
-
3
- ## 2.3.30
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies
8
- - pqb@0.9.17
9
-
10
- ## 2.3.29
11
-
12
- ### Patch Changes
13
-
14
- - Updated dependencies
15
- - pqb@0.9.16
16
-
17
- ## 2.3.28
18
-
19
- ### Patch Changes
20
-
21
- - Support enum in rake-db
22
-
23
- ## 2.3.26
24
-
25
- ### Patch Changes
26
-
27
- - Add createEnum and dropEnum to rake-db
28
- - Updated dependencies
29
- - pqb@0.9.15
30
-
31
- ## 2.3.25
32
-
33
- ### Patch Changes
34
-
35
- - Updated dependencies
36
- - pqb@0.9.14
37
-
38
- ## 2.3.24
39
-
40
- ### Patch Changes
41
-
42
- - Handle ssl required case in db create; Confirm db creation before asking for creds
43
-
44
- ## 2.3.23
45
-
46
- ### Patch Changes
47
-
48
- - Updated dependencies
49
- - pqb@0.9.13
50
-
51
- ## 2.3.22
52
-
53
- ### Patch Changes
54
-
55
- - Fix file resolution in CI
56
-
57
- ## 2.3.21
58
-
59
- ### Patch Changes
60
-
61
- - Improve windows support for path resolution
62
-
63
- ## 2.3.20
64
-
65
- ### Patch Changes
66
-
67
- - Fix path resolution
68
-
69
- ## 2.3.19
70
-
71
- ### Patch Changes
72
-
73
- - Fix path resolution
74
-
75
- ## 2.3.18
76
-
77
- ### Patch Changes
78
-
79
- - Relative path in rakeDb config
80
-
81
- ## 2.3.17
82
-
83
- ### Patch Changes
84
-
85
- - Updated dependencies
86
- - pqb@0.9.12
87
-
88
- ## 2.3.16
89
-
90
- ### Patch Changes
91
-
92
- - Updated dependencies
93
- - pqb@0.9.11
94
-
95
- ## 2.3.15
96
-
97
- ### Patch Changes
98
-
99
- - Updated dependencies
100
- - pqb@0.9.10
101
-
102
- ## 2.3.14
103
-
104
- ### Patch Changes
105
-
106
- - Updated dependencies
107
- - pqb@0.9.9
108
-
109
- ## 2.3.13
110
-
111
- ### Patch Changes
112
-
113
- - ee1961e: Make columnTypes optional in configs
114
- - Updated dependencies [ee1961e]
115
- - pqb@0.9.8
116
-
117
- ## 2.3.12
118
-
119
- ### Patch Changes
120
-
121
- - Handle table ordering by foreign key when pulling db
122
- - Updated dependencies
123
- - pqb@0.9.7
124
-
125
- ## 2.3.11
126
-
127
- ### Patch Changes
128
-
129
- - Add generating extension to db pull
130
-
131
- ## 2.3.10
132
-
133
- ### Patch Changes
134
-
135
- - Add custom commands to rake-db
136
-
137
- ## 2.3.9
138
-
139
- ### Patch Changes
140
-
141
- - Add migrate and rollback callbacks
142
-
143
- ## 2.3.8
144
-
145
- ### Patch Changes
146
-
147
- - Updated dependencies
148
- - pqb@0.9.6
149
-
150
- ## 2.3.7
151
-
152
- ### Patch Changes
153
-
154
- - Mix query builder into migration db interface
155
- - Updated dependencies
156
- - pqb@0.9.5
157
-
158
- ## 2.3.6
159
-
160
- ### Patch Changes
161
-
162
- - Improve esm support
163
- - Updated dependencies
164
- - pqb@0.9.4
165
-
166
- ## 2.3.5
167
-
168
- ### Patch Changes
169
-
170
- - Change package.json exports for esm support
171
- - Updated dependencies
172
- - pqb@0.9.3
173
-
174
- ## 2.3.4
175
-
176
- ### Patch Changes
177
-
178
- - Remove createJoinTable
179
-
180
- ## 2.3.3
181
-
182
- ### Patch Changes
183
-
184
- - Improve pullindg db structure
185
-
186
- ## 2.3.2
187
-
188
- ### Patch Changes
189
-
190
- - Improve pulling db structure
191
- - Updated dependencies
192
- - pqb@0.9.2
193
-
194
- ## 2.3.1
195
-
196
- ### Patch Changes
197
-
198
- - Add command for pulling database structure into a migration
199
- - Updated dependencies
200
- - pqb@0.9.1
201
-
202
- ## 2.3.0
203
-
204
- ### Minor Changes
205
-
206
- - Change index options: column or expression is required, operator renamed to opclass
207
-
208
- ### Patch Changes
209
-
210
- - f1cd5db: Handle multiple indexes and foreignKeys of the column
211
- - Updated dependencies
212
- - Updated dependencies [f1cd5db]
213
- - pqb@0.9.0
214
-
215
- ## 2.2.6
216
-
217
- ### Patch Changes
218
-
219
- - Change inner aspects of columns
220
- - Updated dependencies
221
- - pqb@0.8.5
222
-
223
- ## 2.2.5
224
-
225
- ### Patch Changes
226
-
227
- - Fix useCodeUpdater option default
228
-
229
- ## 2.2.4
230
-
231
- ### Patch Changes
232
-
233
- - Add --code cli argument to rake-db
234
- - Improve codegen
235
- - Updated dependencies
236
- - Updated dependencies
237
- - pqb@0.8.4
238
-
239
- ## 2.2.3
240
-
241
- ### Patch Changes
242
-
243
- - Updated dependencies
244
- - pqb@0.8.3
245
-
246
- ## 2.2.2
247
-
248
- ### Patch Changes
249
-
250
- - Add code generator to change project files after migrations
251
- - Updated dependencies
252
- - pqb@0.8.2
253
-
254
- ## 2.2.1
255
-
256
- ### Patch Changes
257
-
258
- - Updated dependencies
259
- - pqb@0.8.1
260
-
261
- ## 2.2.0
262
-
263
- ### Minor Changes
264
-
265
- - 3f25b4d: Rename all model words to table words, because all models here are not models in OOP meaning
266
-
267
- ### Patch Changes
268
-
269
- - Updated dependencies [3f25b4d]
270
- - pqb@0.8.0
271
-
272
- ## 2.1.18
273
-
274
- ### Patch Changes
275
-
276
- - Updated dependencies
277
- - pqb@0.7.13
278
-
279
- ## 2.1.17
280
-
281
- ### Patch Changes
282
-
283
- - Support composite primary key by setting primaryKey on multiple columns
284
-
285
- ## 2.1.16
286
-
287
- ### Patch Changes
288
-
289
- - Updated dependencies
290
- - pqb@0.7.12
291
-
292
- ## 2.1.15
293
-
294
- ### Patch Changes
295
-
296
- - Fix creating a transaction
297
-
298
- ## 2.1.14
299
-
300
- ### Patch Changes
301
-
302
- - Updated dependencies
303
- - pqb@0.7.11
304
-
305
- ## 2.1.13
306
-
307
- ### Patch Changes
308
-
309
- - Updated dependencies
310
- - pqb@0.7.10
311
-
312
- ## 2.1.12
313
-
314
- ### Patch Changes
315
-
316
- - Updated dependencies
317
- - pqb@0.7.9
318
-
319
- ## 2.1.11
320
-
321
- ### Patch Changes
322
-
323
- - Change connectionString to databaseURL option, add ssl option
324
- - Updated dependencies
325
- - pqb@0.7.8
326
-
327
- ## 2.1.10
328
-
329
- ### Patch Changes
330
-
331
- - Updated dependencies
332
- - pqb@0.7.7
333
-
334
- ## 2.1.9
335
-
336
- ### Patch Changes
337
-
338
- - Updated dependencies
339
- - pqb@0.7.6
340
-
341
- ## 2.1.8
342
-
343
- ### Patch Changes
344
-
345
- - Updated dependencies
346
- - pqb@0.7.5
347
-
348
- ## 2.1.7
349
-
350
- ### Patch Changes
351
-
352
- - Update homepage link in package.json
353
- - Updated dependencies
354
- - pqb@0.7.4
355
-
356
- ## 2.1.6
357
-
358
- ### Patch Changes
359
-
360
- - Add required min and max parameters to text column
361
- - Updated dependencies
362
- - pqb@0.7.3
363
-
364
- ## 2.1.5
365
-
366
- ### Patch Changes
367
-
368
- - Updated dependencies [9b8b3d5]
369
- - pqb@0.7.2
370
-
371
- ## 2.1.4
372
-
373
- ### Patch Changes
374
-
375
- - Handle tables without primary key
376
- - ecd7521: Support copy
377
- - Updated dependencies
378
- - pqb@0.7.1
379
-
380
- ## 2.1.3
381
-
382
- ### Patch Changes
383
-
384
- - 06b0182: Support changing compression, index, and foreign key to changeTable migration
385
-
386
- ## 2.1.0
387
-
388
- ### Minor Changes
389
-
390
- - 883c3e4: Add changeset
391
-
392
- ### Patch Changes
393
-
394
- - Updated dependencies [883c3e4]
395
- - pqb@0.7.0
package/app/dbScript.ts DELETED
@@ -1,33 +0,0 @@
1
- import { config } from 'dotenv';
2
- import path from 'path';
3
- import { rakeDb } from '../src/rakeDb';
4
- import { AdapterOptions } from 'pqb';
5
- import { appCodeUpdater } from '../../orm/src';
6
-
7
- config({ path: path.resolve('.env.local') });
8
- config();
9
-
10
- const options: AdapterOptions[] = [];
11
-
12
- const databaseURL = process.env.DATABASE_URL;
13
- if (!databaseURL) {
14
- throw new Error('DATABASE_URL is missing in .env');
15
- }
16
-
17
- options.push({ databaseURL });
18
-
19
- const databaseURLTest = process.env.DATABASE_URL_TEST;
20
- if (databaseURLTest) {
21
- options.push({ databaseURL: databaseURLTest });
22
- }
23
-
24
- rakeDb(options, {
25
- migrationsPath: 'migrations',
26
- appCodeUpdater: appCodeUpdater({
27
- tablePath: (tableName) => `tables/${tableName}.ts`,
28
- baseTablePath: 'lib/baseTable.ts',
29
- baseTableName: 'BaseTable',
30
- mainFilePath: 'db.ts',
31
- }),
32
- useCodeUpdater: false,
33
- });
@@ -1,14 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('user', (t) => ({
5
- id: t.serial().primaryKey(),
6
- name: t.text(),
7
- password: t.text(),
8
- picture: t.text().nullable(),
9
- data: t.json((t) => t.any()).nullable(),
10
- age: t.integer().nullable(),
11
- active: t.boolean().nullable(),
12
- ...t.timestamps(),
13
- }));
14
- });
@@ -1,10 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('profile', (t) => ({
5
- id: t.serial().primaryKey(),
6
- userId: t.integer().foreignKey('user', 'id').nullable(),
7
- bio: t.text().nullable(),
8
- ...t.timestamps(),
9
- }));
10
- });
@@ -1,9 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('chat', (t) => ({
5
- id: t.serial().primaryKey(),
6
- title: t.text(),
7
- ...t.timestamps(),
8
- }));
9
- });
@@ -1,10 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('chatUser', (t) => ({
5
- chatId: t.integer().foreignKey('chat', 'id'),
6
- userId: t.integer().foreignKey('user', 'id'),
7
- ...t.timestamps(),
8
- ...t.primaryKey(['chatId', 'userId']),
9
- }));
10
- });
@@ -1,12 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('message', (t) => ({
5
- id: t.serial().primaryKey(),
6
- chatId: t.integer().foreignKey('chat', 'id').index(),
7
- authorId: t.integer().foreignKey('user', 'id').nullable().index(),
8
- text: t.text(),
9
- meta: t.json((t) => t.any()).nullable(),
10
- ...t.timestamps(),
11
- }));
12
- });
@@ -1,5 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createSchema('geo');
5
- });
@@ -1,8 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('geo.country', (t) => ({
5
- id: t.serial().primaryKey(),
6
- name: t.text(),
7
- }));
8
- });
@@ -1,9 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('geo.city', (t) => ({
5
- id: t.serial().primaryKey(),
6
- name: t.text(),
7
- countryId: t.integer().foreignKey('geo.country', 'id'),
8
- }));
9
- });
@@ -1,12 +0,0 @@
1
- import { change } from '../../src';
2
-
3
- change(async (db) => {
4
- await db.createTable('uniqueTable', (t) => ({
5
- id: t.serial().primaryKey(),
6
- one: t.text().unique(),
7
- two: t.integer().unique(),
8
- thirdColumn: t.text(),
9
- fourthColumn: t.integer(),
10
- ...t.unique(['thirdColumn', 'fourthColumn']),
11
- }));
12
- });
package/jest-setup.ts DELETED
@@ -1,3 +0,0 @@
1
- jest.mock('pqb', () => require('../qb/pqb/src'), {
2
- virtual: true,
3
- });
package/rollup.config.js DELETED
@@ -1,3 +0,0 @@
1
- import config from '../../rollup.config';
2
-
3
- export default config;