rads-db 3.2.3 → 3.2.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/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { g as RadsConfig, T as TypeDefinition } from './types-9a0ba02b.js';
1
+ import { g as RadsConfig, T as TypeDefinition } from './types-17bcd41b.js';
2
2
  import 'mssql';
3
3
  import '_rads-db';
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EntityDecoratorArgs, U as UiDecoratorArgs, a as UiFieldDecoratorArgs, V as ValidateEntityDecoratorArgs, b as ValidateFieldDecoratorArgs, F as FieldDecoratorArgs, C as ComputedDecoratorArgs, S as Schema, D as DriverConstructor, c as Driver, d as ComputedContext, R as RadsRequestContext, e as CreateRadsDbArgs, f as CreateRadsDbClientArgs } from './types-9a0ba02b.js';
2
- export { O as Change, x as ComputedContextGlobal, k as CreateRadsArgsDrivers, m as CreateRadsDbArgsNormalized, ak as DeepKeys, af as DeepPartial, ad as DeepPartialWithNulls, ae as DeepPartialWithNullsItem, al as EntityMethods, w as EnumDefinition, v as FieldDefinition, J as FileSystemNode, u as FileUploadArgs, q as FileUploadDriver, p as FileUploadResult, H as GenerateClientNormalizedOptions, B as GenerateClientOptions, a9 as Get, $ as GetAggArgs, a0 as GetAggArgsAgg, a3 as GetAggArgsAny, a6 as GetAggResponse, _ as GetArgs, a2 as GetArgsAny, a5 as GetArgsInclude, Q as GetManyArgs, a1 as GetManyArgsAny, a7 as GetManyResponse, a8 as GetResponse, aa as GetResponseInclude, ab as GetResponseIncludeSelect, ac as GetResponseNoInclude, s as GetRestRoutesArgs, G as GetRestRoutesOptions, t as GetRestRoutesResponse, ah as InverseRelation, M as MinimalDriver, aj as Put, ai as PutArgs, P as PutEffect, g as RadsConfig, h as RadsConfigDataSource, r as RadsDbInstance, N as RadsFeature, y as RadsHookDoc, L as RadsUiSlotDefinition, K as RadsUiSlotName, I as RadsVitePluginOptions, ag as Relation, i as RequiredFields, l as RestDriverOptions, A as RestFileUploadDriverOptions, n as SchemaLoadResult, o as SchemaValidators, z as SqlDriverOptions, T as TypeDefinition, j as ValidateStringDecoratorArgs, X as VerifyManyArgs, a4 as VerifyManyArgsAny, Y as VerifyManyResponse, Z as Where, W as WhereJsonContains } from './types-9a0ba02b.js';
1
+ import { E as EntityDecoratorArgs, U as UiDecoratorArgs, a as UiFieldDecoratorArgs, V as ValidateEntityDecoratorArgs, b as ValidateFieldDecoratorArgs, F as FieldDecoratorArgs, C as ComputedDecoratorArgs, S as Schema, D as DriverConstructor, c as Driver, d as ComputedContext, R as RadsRequestContext, e as CreateRadsDbArgs, f as CreateRadsDbClientArgs } from './types-17bcd41b.js';
2
+ export { O as Change, x as ComputedContextGlobal, k as CreateRadsArgsDrivers, m as CreateRadsDbArgsNormalized, ak as DeepKeys, af as DeepPartial, ad as DeepPartialWithNulls, ae as DeepPartialWithNullsItem, al as EntityMethods, w as EnumDefinition, v as FieldDefinition, J as FileSystemNode, u as FileUploadArgs, q as FileUploadDriver, p as FileUploadResult, H as GenerateClientNormalizedOptions, B as GenerateClientOptions, a9 as Get, $ as GetAggArgs, a0 as GetAggArgsAgg, a3 as GetAggArgsAny, a6 as GetAggResponse, _ as GetArgs, a2 as GetArgsAny, a5 as GetArgsInclude, Q as GetManyArgs, a1 as GetManyArgsAny, a7 as GetManyResponse, a8 as GetResponse, aa as GetResponseInclude, ab as GetResponseIncludeSelect, ac as GetResponseNoInclude, s as GetRestRoutesArgs, G as GetRestRoutesOptions, t as GetRestRoutesResponse, ah as InverseRelation, M as MinimalDriver, aj as Put, ai as PutArgs, P as PutEffect, g as RadsConfig, h as RadsConfigDataSource, r as RadsDbInstance, N as RadsFeature, y as RadsHookDoc, L as RadsUiSlotDefinition, K as RadsUiSlotName, I as RadsVitePluginOptions, ag as Relation, i as RequiredFields, l as RestDriverOptions, A as RestFileUploadDriverOptions, n as SchemaLoadResult, o as SchemaValidators, z as SqlDriverOptions, T as TypeDefinition, j as ValidateStringDecoratorArgs, X as VerifyManyArgs, a4 as VerifyManyArgsAny, Y as VerifyManyResponse, Z as Where, W as WhereJsonContains } from './types-17bcd41b.js';
3
3
  import { RadsDb } from '_rads-db';
4
4
  export { RadsDb } from '_rads-db';
5
5
  import 'mssql';
@@ -325,7 +325,10 @@ interface MinimalDriver {
325
325
  deleteAll?: (args: GetManyArgsAny, ctx?: RadsRequestContext) => MaybePromise<Record<string, any>[]>;
326
326
  put?: (data: Record<string, any>, ctx?: RadsRequestContext) => MaybePromise<void>;
327
327
  verifyMany?: (args?: VerifyManyArgsAny, ctx?: RadsRequestContext) => MaybePromise<VerifyManyResponse>;
328
- generateMigrationScript?: () => MaybePromise<string | undefined>;
328
+ generateMigrationScript?: () => MaybePromise<{
329
+ createScript: string;
330
+ dropScript: string;
331
+ }>;
329
332
  }
330
333
  type Driver = Required<Omit<MinimalDriver, 'verifyMany' | 'client' | 'generateMigrationScript'>> & Pick<MinimalDriver, 'verifyMany' | 'client' | 'generateMigrationScript'>;
331
334
  interface FieldDefinition {
package/drivers/sql.cjs CHANGED
@@ -386,12 +386,17 @@ ${insertQuery.slice(0, 300)}...`);
386
386
  const entity2 = schema2[entityName];
387
387
  if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
388
388
  const createTableRequest1 = getCreateTableRequestsFor(entityName, {
389
- tableNamePrefix: options.tablePrefix
389
+ tableNamePrefix: options.tablePrefix,
390
+ dropIfExists: true
390
391
  });
391
392
  const createTableRequest2 = getCreateTableRequestsFor(entityName, {
392
- tableNamePrefix: options.stagingTablePrefix
393
+ tableNamePrefix: options.stagingTablePrefix,
394
+ dropIfExists: true
393
395
  });
394
- return [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n");
396
+ return {
397
+ dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
398
+ createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
399
+ };
395
400
  }
396
401
  function getCreateTableRequestsFor(entityName, options2) {
397
402
  const {
package/drivers/sql.mjs CHANGED
@@ -256,11 +256,18 @@ ${insertQuery.slice(0, 300)}...`);
256
256
  function buildMigrationScript(schema2, entityName) {
257
257
  const entity2 = schema2[entityName];
258
258
  if (!entity2) throw new Error(`Entity "${entityName}" not found in schema`);
259
- const createTableRequest1 = getCreateTableRequestsFor(entityName, { tableNamePrefix: options.tablePrefix });
259
+ const createTableRequest1 = getCreateTableRequestsFor(entityName, {
260
+ tableNamePrefix: options.tablePrefix,
261
+ dropIfExists: true
262
+ });
260
263
  const createTableRequest2 = getCreateTableRequestsFor(entityName, {
261
- tableNamePrefix: options.stagingTablePrefix
264
+ tableNamePrefix: options.stagingTablePrefix,
265
+ dropIfExists: true
262
266
  });
263
- return [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n");
267
+ return {
268
+ dropScript: [...createTableRequest1.dropRequests, ...createTableRequest2.dropRequests].join(";\n\n"),
269
+ createScript: [...createTableRequest1.createRequests, ...createTableRequest2.createRequests].join(";\n\n")
270
+ };
264
271
  }
265
272
  function getCreateTableRequestsFor(entityName, options2) {
266
273
  const { tableNameSuffix, tableNamePrefix, dropIfExists, addPrimaryKey, addForeignKeys, foreignKeysTables } = options2 || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
5
5
  "author": "",
6
6
  "license": "ISC",