arkormx 2.0.11 → 2.1.1
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/README.md +5 -5
- package/dist/cli.mjs +113 -16
- package/dist/{index-BJDRQWuc.d.mts → index-BQyFSgj_.d.cts} +22 -3
- package/dist/{index-D2xzn3OX.d.cts → index-RvyusnXP.d.mts} +22 -3
- package/dist/index.cjs +153 -17
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +153 -18
- package/dist/relationship/index.cjs +1 -1
- package/dist/relationship/index.d.cts +1 -1
- package/dist/relationship/index.d.mts +1 -1
- package/dist/relationship/index.mjs +1 -1
- package/dist/{relationship-RG9V2vgd.mjs → relationship-BBMs-1iK.mjs} +4 -1
- package/dist/{relationship-CG78rqWf.cjs → relationship-BRQjsdj3.cjs} +9 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $ as PRISMA_ENUM_MEMBER_REGEX, $t as
|
|
1
|
+
import { $ as PRISMA_ENUM_MEMBER_REGEX, $t as findAppliedMigration, A as isDelegateLike, At as getMigrationPlan, B as getPersistedEnumMap, Bt as supportsDatabaseReset, C as getRuntimeAdapter, Ct as escapeRegex, D as getRuntimePaginationURLDriverFactory, Dt as formatEnumDefaultValue, E as getRuntimePaginationCurrentPageResolver, Et as formatDefaultValue, F as runArkormTransaction, Ft as runMigrationWithPrisma, G as readPersistedColumnMappingsState, Gt as TableBuilder, H as getPersistedPrimaryKeyGeneration, Ht as toModelName, I as applyOperationsToPersistedColumnMappingsState, It as runPrismaCommand, J as resolveColumnMappingsFilePath, Jt as buildMigrationIdentity, K as rebuildPersistedColumnMappingsState, Kt as ForeignKeyBuilder, L as createEmptyPersistedColumnMappingsState, Lt as stripPrismaSchemaModelsAndEnums, M as isTransactionCapableClient, Mt as resolveEnumName, N as loadArkormConfig, Nt as resolveMigrationClassName, O as getRuntimePrismaClient, Ot as formatRelationAction, P as resetArkormRuntimeForTests, Pt as resolvePrismaType, Q as writePersistedColumnMappingsState, Qt as deleteAppliedMigrationsStateFromStore, R as deletePersistedColumnMappingsState, Rt as supportsDatabaseCreation, S as getDefaultStubsPath, St as deriveSingularFieldName, T as getRuntimeDebugHandler, Tt as findModelBlock, U as getPersistedTableMetadata, Ut as SchemaBuilder, V as getPersistedEnumTsType, Vt as toMigrationFileSlug, W as getPersistedTimestampColumns, Wt as EnumBuilder, X as syncPersistedColumnMappingsFromState, Xt as computeMigrationChecksum, Y as resolvePersistedMetadataFeatures, Yt as buildMigrationRunId, Z as validatePersistedMetadataFeaturesForMigrations, Zt as createEmptyAppliedMigrationsState, _ as defineConfig, _n as ArkormCollection, _t as createMigrationTimestamp, a as HasOneRelation, an as readAppliedMigrationsState, at as applyMigrationRollbackToDatabase, b as getActiveTransactionAdapter, bt as deriveRelationAlias, c as BelongsToRelation, cn as resolveMigrationStateFilePath, ct as applyMigrationToPrismaSchema, d as Relation, dn as writeAppliedMigrationsStateToStore, dt as buildFieldLine, en as getLastMigrationRun, et as PRISMA_ENUM_REGEX, f as LengthAwarePaginator, fn as RuntimeModuleLoader, ft as buildIndexLine, g as configureArkormRuntime, gn as RelationResolutionException, gt as buildRelationLine, h as bindAdapterToModels, ht as buildModelBlock, i as HasOneThroughRelation, in as markMigrationRun, it as applyDropTableOperation, j as isQuerySchemaLike, jt as pad, k as getUserConfig, kt as generateMigrationFile, ln as supportsDatabaseMigrationState, lt as applyOperationsToPrismaSchema, m as URLDriver, mn as SetBasedEagerLoader, mt as buildMigrationSource, n as MorphOneRelation, nn as isMigrationApplied, nt as applyAlterTableOperation, o as HasManyThroughRelation, on as readAppliedMigrationsStateFromStore, ot as applyMigrationRollbackToPrismaSchema, p as Paginator, pn as UnsupportedAdapterFeatureException, pt as buildInverseRelationLine, q as resetPersistedColumnMappingsCache, qt as PrimaryKeyGenerationPlanner, r as MorphManyRelation, rn as markMigrationApplied, rt as applyCreateTableOperation, s as HasManyRelation, sn as removeAppliedMigration, st as applyMigrationToDatabase, t as MorphToManyRelation, tn as getLatestAppliedMigrations, tt as PRISMA_MODEL_REGEX, u as BelongsToManyRelation, un as writeAppliedMigrationsState, ut as buildEnumBlock, v as emitRuntimeDebugEvent, vn as ArkormException, vt as deriveCollectionFieldName, w as getRuntimeClient, wt as findEnumBlock, x as getActiveTransactionClient, xt as deriveRelationFieldName, y as ensureArkormConfigLoading, yt as deriveInverseRelationAlias, z as getPersistedColumnMap, zt as supportsDatabaseMigrationExecution } from "./relationship-BBMs-1iK.mjs";
|
|
2
|
+
import { Pool } from "pg";
|
|
2
3
|
import { join, resolve } from "node:path";
|
|
3
4
|
import { createRequire } from "module";
|
|
4
5
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "fs";
|
|
@@ -61,6 +62,25 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
61
62
|
rawWhere: true
|
|
62
63
|
};
|
|
63
64
|
}
|
|
65
|
+
resolveConfiguredDatabaseName(connectionString) {
|
|
66
|
+
const parsed = new URL(connectionString);
|
|
67
|
+
const database = decodeURIComponent(parsed.pathname.replace(/^\/+/, ""));
|
|
68
|
+
if (database.length === 0) throw new ArkormException("Unable to resolve the configured database name from the Kysely connection string.");
|
|
69
|
+
return database;
|
|
70
|
+
}
|
|
71
|
+
createMaintenanceConnectionString(connectionString) {
|
|
72
|
+
const parsed = new URL(connectionString);
|
|
73
|
+
parsed.pathname = "/postgres";
|
|
74
|
+
parsed.searchParams.delete("schema");
|
|
75
|
+
parsed.searchParams.delete("options");
|
|
76
|
+
return parsed.toString();
|
|
77
|
+
}
|
|
78
|
+
getMissingDatabaseNameFromError(error) {
|
|
79
|
+
const candidate = error;
|
|
80
|
+
const matched = (typeof candidate?.message === "string" ? candidate.message : "").match(/database "([^"]+)" does not exist/i);
|
|
81
|
+
if (candidate?.code === "3D000" && matched?.[1]) return matched[1];
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
64
84
|
quoteIdentifier(value) {
|
|
65
85
|
return `"${value.replace(/"/g, "\"\"")}"`;
|
|
66
86
|
}
|
|
@@ -1074,6 +1094,27 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1074
1094
|
await trxAdapter.resetDatabaseInternal(trxAdapter.db);
|
|
1075
1095
|
});
|
|
1076
1096
|
}
|
|
1097
|
+
async createDatabaseFromError(error) {
|
|
1098
|
+
const database = this.getMissingDatabaseNameFromError(error);
|
|
1099
|
+
if (!database) return null;
|
|
1100
|
+
const connectionString = process.env.DATABASE_URL;
|
|
1101
|
+
if (!connectionString) throw new ArkormException("Unable to create the missing database because DATABASE_URL is not available.");
|
|
1102
|
+
if (this.resolveConfiguredDatabaseName(connectionString) !== database) throw new ArkormException(`Unable to create database [${database}] because it does not match the database configured by DATABASE_URL.`);
|
|
1103
|
+
const pool = new Pool({ connectionString: this.createMaintenanceConnectionString(connectionString) });
|
|
1104
|
+
try {
|
|
1105
|
+
if ((await pool.query("select exists(select 1 from pg_database where datname = $1) as exists", [database])).rows[0]?.exists === true) return {
|
|
1106
|
+
database,
|
|
1107
|
+
created: false
|
|
1108
|
+
};
|
|
1109
|
+
await pool.query(`create database ${this.quoteIdentifier(database)}`);
|
|
1110
|
+
return {
|
|
1111
|
+
database,
|
|
1112
|
+
created: true
|
|
1113
|
+
};
|
|
1114
|
+
} finally {
|
|
1115
|
+
await pool.end();
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1077
1118
|
async readAppliedMigrationsState() {
|
|
1078
1119
|
await this.ensureMigrationStateTables();
|
|
1079
1120
|
const migrationsResult = await sql`
|
|
@@ -2731,6 +2772,7 @@ var MigrateCommand = class extends Command {
|
|
|
2731
2772
|
{--state-file= : Path to applied migration state file}
|
|
2732
2773
|
{--schema= : Explicit prisma schema path}
|
|
2733
2774
|
{--migration-name= : Name for prisma migrate dev}
|
|
2775
|
+
{--create-database : Create the configured database without prompting}
|
|
2734
2776
|
`;
|
|
2735
2777
|
this.description = "Apply migration classes to schema.prisma and run Prisma workflow";
|
|
2736
2778
|
}
|
|
@@ -2752,19 +2794,21 @@ var MigrateCommand = class extends Command {
|
|
|
2752
2794
|
const classes = this.option("all") || !this.argument("name") ? await this.loadAllMigrations(migrationsDir) : (await this.loadNamedMigration(migrationsDir, this.argument("name"))).filter(([cls]) => cls !== void 0);
|
|
2753
2795
|
if (classes.length === 0) return void this.error("Error: No migration classes found to run.");
|
|
2754
2796
|
const stateFilePath = resolveMigrationStateFilePath(process.cwd(), this.option("state-file") ? String(this.option("state-file")) : void 0);
|
|
2755
|
-
let appliedState = await readAppliedMigrationsStateFromStore(this.app.getConfig("adapter"), stateFilePath);
|
|
2756
2797
|
const adapter = this.app.getConfig("adapter");
|
|
2757
2798
|
const useDatabaseMigrations = supportsDatabaseMigrationExecution(adapter);
|
|
2758
2799
|
const persistedFeatures = resolvePersistedMetadataFeatures(this.app.getConfig("features"));
|
|
2800
|
+
const appliedState = await this.runWithDatabaseCreationRetry(adapter, () => readAppliedMigrationsStateFromStore(adapter, stateFilePath));
|
|
2801
|
+
if (!appliedState.ok) return;
|
|
2802
|
+
let appliedMigrationState = appliedState.value;
|
|
2759
2803
|
const skipped = [];
|
|
2760
2804
|
const changed = [];
|
|
2761
2805
|
const pending = classes.filter(([migrationClass, file]) => {
|
|
2762
|
-
if (!
|
|
2806
|
+
if (!appliedMigrationState) return true;
|
|
2763
2807
|
const identity = buildMigrationIdentity(file, migrationClass.name);
|
|
2764
2808
|
const checksum = computeMigrationChecksum(file);
|
|
2765
|
-
const alreadyApplied = isMigrationApplied(
|
|
2809
|
+
const alreadyApplied = isMigrationApplied(appliedMigrationState, identity, checksum);
|
|
2766
2810
|
if (alreadyApplied) skipped.push([migrationClass, file]);
|
|
2767
|
-
else if (findAppliedMigration(
|
|
2811
|
+
else if (findAppliedMigration(appliedMigrationState, identity)) changed.push([migrationClass, file]);
|
|
2768
2812
|
return !alreadyApplied;
|
|
2769
2813
|
});
|
|
2770
2814
|
skipped.forEach(([migrationClass, file]) => {
|
|
@@ -2774,8 +2818,8 @@ var MigrateCommand = class extends Command {
|
|
|
2774
2818
|
this.success(this.app.splitLogger("Changed", `${file} (${migrationClass.name})`));
|
|
2775
2819
|
});
|
|
2776
2820
|
if (pending.length === 0) {
|
|
2777
|
-
if (
|
|
2778
|
-
await syncPersistedColumnMappingsFromState(process.cwd(),
|
|
2821
|
+
if (appliedMigrationState) try {
|
|
2822
|
+
await syncPersistedColumnMappingsFromState(process.cwd(), appliedMigrationState, await this.loadAllMigrations(migrationsDir), persistedFeatures);
|
|
2779
2823
|
} catch (error) {
|
|
2780
2824
|
this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
2781
2825
|
return;
|
|
@@ -2791,7 +2835,7 @@ var MigrateCommand = class extends Command {
|
|
|
2791
2835
|
}
|
|
2792
2836
|
for (const [MigrationClassItem] of pending) {
|
|
2793
2837
|
if (useDatabaseMigrations) {
|
|
2794
|
-
await applyMigrationToDatabase(adapter, MigrationClassItem);
|
|
2838
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => applyMigrationToDatabase(adapter, MigrationClassItem))).ok) return;
|
|
2795
2839
|
continue;
|
|
2796
2840
|
}
|
|
2797
2841
|
await applyMigrationToPrismaSchema(MigrationClassItem, {
|
|
@@ -2799,11 +2843,11 @@ var MigrateCommand = class extends Command {
|
|
|
2799
2843
|
write: true
|
|
2800
2844
|
});
|
|
2801
2845
|
}
|
|
2802
|
-
if (
|
|
2846
|
+
if (appliedMigrationState) {
|
|
2803
2847
|
const runAppliedIds = [];
|
|
2804
2848
|
for (const [migrationClass, file] of pending) {
|
|
2805
2849
|
const identity = buildMigrationIdentity(file, migrationClass.name);
|
|
2806
|
-
|
|
2850
|
+
appliedMigrationState = markMigrationApplied(appliedMigrationState, {
|
|
2807
2851
|
id: identity,
|
|
2808
2852
|
file,
|
|
2809
2853
|
className: migrationClass.name,
|
|
@@ -2812,14 +2856,14 @@ var MigrateCommand = class extends Command {
|
|
|
2812
2856
|
});
|
|
2813
2857
|
runAppliedIds.push(identity);
|
|
2814
2858
|
}
|
|
2815
|
-
|
|
2859
|
+
appliedMigrationState = markMigrationRun(appliedMigrationState, {
|
|
2816
2860
|
id: buildMigrationRunId(),
|
|
2817
2861
|
appliedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2818
2862
|
migrationIds: runAppliedIds
|
|
2819
2863
|
});
|
|
2820
|
-
await writeAppliedMigrationsStateToStore(adapter, stateFilePath,
|
|
2864
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedMigrationState))).ok) return;
|
|
2821
2865
|
try {
|
|
2822
|
-
await syncPersistedColumnMappingsFromState(process.cwd(),
|
|
2866
|
+
await syncPersistedColumnMappingsFromState(process.cwd(), appliedMigrationState, await this.loadAllMigrations(migrationsDir), persistedFeatures);
|
|
2823
2867
|
} catch (error) {
|
|
2824
2868
|
this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
2825
2869
|
return;
|
|
@@ -2884,6 +2928,51 @@ var MigrateCommand = class extends Command {
|
|
|
2884
2928
|
return candidate[MIGRATION_BRAND] === true || typeof prototype?.up === "function" && typeof prototype?.down === "function";
|
|
2885
2929
|
});
|
|
2886
2930
|
}
|
|
2931
|
+
async runWithDatabaseCreationRetry(adapter, callback) {
|
|
2932
|
+
if (!supportsDatabaseCreation(adapter)) return {
|
|
2933
|
+
ok: true,
|
|
2934
|
+
value: await callback()
|
|
2935
|
+
};
|
|
2936
|
+
try {
|
|
2937
|
+
return {
|
|
2938
|
+
ok: true,
|
|
2939
|
+
value: await callback()
|
|
2940
|
+
};
|
|
2941
|
+
} catch (error) {
|
|
2942
|
+
const database = this.getMissingDatabaseName(error);
|
|
2943
|
+
if (!database) throw error;
|
|
2944
|
+
if (!await this.shouldCreateDatabase(database)) {
|
|
2945
|
+
this.error(`Error: Configured database [${database}] does not exist.`);
|
|
2946
|
+
return { ok: false };
|
|
2947
|
+
}
|
|
2948
|
+
let created;
|
|
2949
|
+
try {
|
|
2950
|
+
created = await adapter.createDatabaseFromError(error);
|
|
2951
|
+
} catch (creationError) {
|
|
2952
|
+
this.error(`Error: ${creationError instanceof Error ? creationError.message : String(creationError)}`);
|
|
2953
|
+
return { ok: false };
|
|
2954
|
+
}
|
|
2955
|
+
if (!created) {
|
|
2956
|
+
this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
2957
|
+
return { ok: false };
|
|
2958
|
+
}
|
|
2959
|
+
if (created.created) this.success(`Created database: ${created.database ?? database}`);
|
|
2960
|
+
return {
|
|
2961
|
+
ok: true,
|
|
2962
|
+
value: await callback()
|
|
2963
|
+
};
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
getMissingDatabaseName(error) {
|
|
2967
|
+
const candidate = error;
|
|
2968
|
+
const matched = (typeof candidate?.message === "string" ? candidate.message : "").match(/database "([^"]+)" does not exist/i);
|
|
2969
|
+
if (candidate?.code === "3D000" && matched?.[1]) return matched[1];
|
|
2970
|
+
}
|
|
2971
|
+
async shouldCreateDatabase(database) {
|
|
2972
|
+
if (this.option("create-database")) return true;
|
|
2973
|
+
if (this.isNonInteractive()) return false;
|
|
2974
|
+
return await this.confirm(`Configured database${database ? ` [${database}]` : ""} does not exist. Create it before running migrations?`, true);
|
|
2975
|
+
}
|
|
2887
2976
|
};
|
|
2888
2977
|
|
|
2889
2978
|
//#endregion
|
|
@@ -2896,6 +2985,7 @@ var MigrateFreshCommand = class extends Command {
|
|
|
2896
2985
|
{--skip-migrate : Skip prisma database sync}
|
|
2897
2986
|
{--state-file= : Path to applied migration state file}
|
|
2898
2987
|
{--schema= : Explicit prisma schema path}
|
|
2988
|
+
{--create-database : Create the configured database without prompting}
|
|
2899
2989
|
`;
|
|
2900
2990
|
this.description = "Reset the database and rerun all migration classes";
|
|
2901
2991
|
}
|
|
@@ -2922,16 +3012,16 @@ var MigrateFreshCommand = class extends Command {
|
|
|
2922
3012
|
this.error("Error: Your current database adapter does not support database reset.");
|
|
2923
3013
|
return;
|
|
2924
3014
|
}
|
|
2925
|
-
await adapter.resetDatabase();
|
|
3015
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => adapter.resetDatabase())).ok) return;
|
|
2926
3016
|
} else {
|
|
2927
3017
|
if (!existsSync$1(schemaPath)) return void this.error(`Error: Prisma schema file not found: ${this.app.formatPathForLog(schemaPath)}`);
|
|
2928
3018
|
writeFileSync$1(schemaPath, stripPrismaSchemaModelsAndEnums(readFileSync$1(schemaPath, "utf-8")));
|
|
2929
3019
|
}
|
|
2930
3020
|
let appliedState = createEmptyAppliedMigrationsState();
|
|
2931
|
-
await writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState);
|
|
3021
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState))).ok) return;
|
|
2932
3022
|
for (const [MigrationClassItem] of migrations) {
|
|
2933
3023
|
if (useDatabaseMigrations) {
|
|
2934
|
-
await applyMigrationToDatabase(adapter, MigrationClassItem);
|
|
3024
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => applyMigrationToDatabase(adapter, MigrationClassItem))).ok) return;
|
|
2935
3025
|
continue;
|
|
2936
3026
|
}
|
|
2937
3027
|
await applyMigrationToPrismaSchema(MigrationClassItem, {
|
|
@@ -2951,7 +3041,7 @@ var MigrateFreshCommand = class extends Command {
|
|
|
2951
3041
|
appliedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2952
3042
|
migrationIds: appliedState.migrations.map((migration) => migration.id)
|
|
2953
3043
|
});
|
|
2954
|
-
await writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState);
|
|
3044
|
+
if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState))).ok) return;
|
|
2955
3045
|
try {
|
|
2956
3046
|
await syncPersistedColumnMappingsFromState(process.cwd(), appliedState, migrations, persistedFeatures);
|
|
2957
3047
|
} catch (error) {
|
|
@@ -2984,6 +3074,51 @@ var MigrateFreshCommand = class extends Command {
|
|
|
2984
3074
|
return candidate[MIGRATION_BRAND] === true || typeof prototype?.up === "function" && typeof prototype?.down === "function";
|
|
2985
3075
|
});
|
|
2986
3076
|
}
|
|
3077
|
+
async runWithDatabaseCreationRetry(adapter, callback) {
|
|
3078
|
+
if (!supportsDatabaseCreation(adapter)) return {
|
|
3079
|
+
ok: true,
|
|
3080
|
+
value: await callback()
|
|
3081
|
+
};
|
|
3082
|
+
try {
|
|
3083
|
+
return {
|
|
3084
|
+
ok: true,
|
|
3085
|
+
value: await callback()
|
|
3086
|
+
};
|
|
3087
|
+
} catch (error) {
|
|
3088
|
+
const database = this.getMissingDatabaseName(error);
|
|
3089
|
+
if (!database) throw error;
|
|
3090
|
+
if (!await this.shouldCreateDatabase(database)) {
|
|
3091
|
+
this.error(`Error: Configured database [${database}] does not exist.`);
|
|
3092
|
+
return { ok: false };
|
|
3093
|
+
}
|
|
3094
|
+
let created;
|
|
3095
|
+
try {
|
|
3096
|
+
created = await adapter.createDatabaseFromError(error);
|
|
3097
|
+
} catch (creationError) {
|
|
3098
|
+
this.error(`Error: ${creationError instanceof Error ? creationError.message : String(creationError)}`);
|
|
3099
|
+
return { ok: false };
|
|
3100
|
+
}
|
|
3101
|
+
if (!created) {
|
|
3102
|
+
this.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
3103
|
+
return { ok: false };
|
|
3104
|
+
}
|
|
3105
|
+
if (created.created) this.success(`Created database: ${created.database ?? database}`);
|
|
3106
|
+
return {
|
|
3107
|
+
ok: true,
|
|
3108
|
+
value: await callback()
|
|
3109
|
+
};
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
getMissingDatabaseName(error) {
|
|
3113
|
+
const candidate = error;
|
|
3114
|
+
const matched = (typeof candidate?.message === "string" ? candidate.message : "").match(/database "([^"]+)" does not exist/i);
|
|
3115
|
+
if (candidate?.code === "3D000" && matched?.[1]) return matched[1];
|
|
3116
|
+
}
|
|
3117
|
+
async shouldCreateDatabase(database) {
|
|
3118
|
+
if (this.option("create-database")) return true;
|
|
3119
|
+
if (this.isNonInteractive()) return false;
|
|
3120
|
+
return await this.confirm(`Configured database${database ? ` [${database}]` : ""} does not exist. Create it before running migrations?`, true);
|
|
3121
|
+
}
|
|
2987
3122
|
};
|
|
2988
3123
|
|
|
2989
3124
|
//#endregion
|
|
@@ -7194,4 +7329,4 @@ var PivotModel = class extends Model {
|
|
|
7194
7329
|
};
|
|
7195
7330
|
|
|
7196
7331
|
//#endregion
|
|
7197
|
-
export { ArkormCollection, ArkormException, Attribute, CliApp, DB, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isQuerySchemaLike, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
|
7332
|
+
export { ArkormCollection, ArkormException, Attribute, CliApp, DB, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isQuerySchemaLike, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_relationship = require('../relationship-
|
|
2
|
+
const require_relationship = require('../relationship-BRQjsdj3.cjs');
|
|
3
3
|
|
|
4
4
|
exports.BelongsToManyRelation = require_relationship.BelongsToManyRelation;
|
|
5
5
|
exports.BelongsToRelation = require_relationship.BelongsToRelation;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ba as SingleResultRelation, Fa as HasOneThroughRelation, Ha as Relation, Ia as HasOneRelation, La as HasManyThroughRelation, Ma as MorphToManyRelation, Na as MorphOneRelation, Pa as MorphManyRelation, Ra as HasManyRelation, Ua as RelationTableLoader, Va as BelongsToManyRelation, ja as SetBasedEagerLoader, za as BelongsToRelation } from "../index-BQyFSgj_.cjs";
|
|
2
2
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ba as SingleResultRelation, Fa as HasOneThroughRelation, Ha as Relation, Ia as HasOneRelation, La as HasManyThroughRelation, Ma as MorphToManyRelation, Na as MorphOneRelation, Pa as MorphManyRelation, Ra as HasManyRelation, Ua as RelationTableLoader, Va as BelongsToManyRelation, ja as SetBasedEagerLoader, za as BelongsToRelation } from "../index-RvyusnXP.mjs";
|
|
2
2
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as HasOneRelation, c as BelongsToRelation, d as Relation, i as HasOneThroughRelation, l as SingleResultRelation, mn as
|
|
1
|
+
import { a as HasOneRelation, c as BelongsToRelation, d as Relation, hn as RelationTableLoader, i as HasOneThroughRelation, l as SingleResultRelation, mn as SetBasedEagerLoader, n as MorphOneRelation, o as HasManyThroughRelation, r as MorphManyRelation, s as HasManyRelation, t as MorphToManyRelation, u as BelongsToManyRelation } from "../relationship-BBMs-1iK.mjs";
|
|
2
2
|
|
|
3
3
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -2167,6 +2167,9 @@ const getMigrationPlan = async (migration, direction = "up") => {
|
|
|
2167
2167
|
const supportsDatabaseMigrationExecution = (adapter) => {
|
|
2168
2168
|
return typeof adapter?.executeSchemaOperations === "function";
|
|
2169
2169
|
};
|
|
2170
|
+
const supportsDatabaseCreation = (adapter) => {
|
|
2171
|
+
return typeof adapter?.createDatabaseFromError === "function";
|
|
2172
|
+
};
|
|
2170
2173
|
const supportsDatabaseReset = (adapter) => {
|
|
2171
2174
|
return typeof adapter?.resetDatabase === "function";
|
|
2172
2175
|
};
|
|
@@ -4440,4 +4443,4 @@ var MorphToManyRelation = class extends Relation {
|
|
|
4440
4443
|
};
|
|
4441
4444
|
|
|
4442
4445
|
//#endregion
|
|
4443
|
-
export { PRISMA_ENUM_MEMBER_REGEX as $,
|
|
4446
|
+
export { PRISMA_ENUM_MEMBER_REGEX as $, findAppliedMigration as $t, isDelegateLike as A, getMigrationPlan as At, getPersistedEnumMap as B, supportsDatabaseReset as Bt, getRuntimeAdapter as C, escapeRegex as Ct, getRuntimePaginationURLDriverFactory as D, formatEnumDefaultValue as Dt, getRuntimePaginationCurrentPageResolver as E, formatDefaultValue as Et, runArkormTransaction as F, runMigrationWithPrisma as Ft, readPersistedColumnMappingsState as G, TableBuilder as Gt, getPersistedPrimaryKeyGeneration as H, toModelName as Ht, applyOperationsToPersistedColumnMappingsState as I, runPrismaCommand as It, resolveColumnMappingsFilePath as J, buildMigrationIdentity as Jt, rebuildPersistedColumnMappingsState as K, ForeignKeyBuilder as Kt, createEmptyPersistedColumnMappingsState as L, stripPrismaSchemaModelsAndEnums as Lt, isTransactionCapableClient as M, resolveEnumName as Mt, loadArkormConfig as N, resolveMigrationClassName as Nt, getRuntimePrismaClient as O, formatRelationAction as Ot, resetArkormRuntimeForTests as P, resolvePrismaType as Pt, writePersistedColumnMappingsState as Q, deleteAppliedMigrationsStateFromStore as Qt, deletePersistedColumnMappingsState as R, supportsDatabaseCreation as Rt, getDefaultStubsPath as S, deriveSingularFieldName as St, getRuntimeDebugHandler as T, findModelBlock as Tt, getPersistedTableMetadata as U, SchemaBuilder as Ut, getPersistedEnumTsType as V, toMigrationFileSlug as Vt, getPersistedTimestampColumns as W, EnumBuilder as Wt, syncPersistedColumnMappingsFromState as X, computeMigrationChecksum as Xt, resolvePersistedMetadataFeatures as Y, buildMigrationRunId as Yt, validatePersistedMetadataFeaturesForMigrations as Z, createEmptyAppliedMigrationsState as Zt, defineConfig as _, ArkormCollection as _n, createMigrationTimestamp as _t, HasOneRelation as a, readAppliedMigrationsState as an, applyMigrationRollbackToDatabase as at, getActiveTransactionAdapter as b, deriveRelationAlias as bt, BelongsToRelation as c, resolveMigrationStateFilePath as cn, applyMigrationToPrismaSchema as ct, Relation as d, writeAppliedMigrationsStateToStore as dn, buildFieldLine as dt, getLastMigrationRun as en, PRISMA_ENUM_REGEX as et, LengthAwarePaginator as f, RuntimeModuleLoader as fn, buildIndexLine as ft, configureArkormRuntime as g, RelationResolutionException as gn, buildRelationLine as gt, bindAdapterToModels as h, RelationTableLoader as hn, buildModelBlock as ht, HasOneThroughRelation as i, markMigrationRun as in, applyDropTableOperation as it, isQuerySchemaLike as j, pad as jt, getUserConfig as k, generateMigrationFile as kt, SingleResultRelation as l, supportsDatabaseMigrationState as ln, applyOperationsToPrismaSchema as lt, URLDriver as m, SetBasedEagerLoader as mn, buildMigrationSource as mt, MorphOneRelation as n, isMigrationApplied as nn, applyAlterTableOperation as nt, HasManyThroughRelation as o, readAppliedMigrationsStateFromStore as on, applyMigrationRollbackToPrismaSchema as ot, Paginator as p, UnsupportedAdapterFeatureException as pn, buildInverseRelationLine as pt, resetPersistedColumnMappingsCache as q, PrimaryKeyGenerationPlanner as qt, MorphManyRelation as r, markMigrationApplied as rn, applyCreateTableOperation as rt, HasManyRelation as s, removeAppliedMigration as sn, applyMigrationToDatabase as st, MorphToManyRelation as t, getLatestAppliedMigrations as tn, PRISMA_MODEL_REGEX as tt, BelongsToManyRelation as u, writeAppliedMigrationsState as un, buildEnumBlock as ut, emitRuntimeDebugEvent as v, ArkormException as vn, deriveCollectionFieldName as vt, getRuntimeClient as w, findEnumBlock as wt, getActiveTransactionClient as x, deriveRelationFieldName as xt, ensureArkormConfigLoading as y, deriveInverseRelationAlias as yt, getPersistedColumnMap as z, supportsDatabaseMigrationExecution as zt };
|
|
@@ -2195,6 +2195,9 @@ const getMigrationPlan = async (migration, direction = "up") => {
|
|
|
2195
2195
|
const supportsDatabaseMigrationExecution = (adapter) => {
|
|
2196
2196
|
return typeof adapter?.executeSchemaOperations === "function";
|
|
2197
2197
|
};
|
|
2198
|
+
const supportsDatabaseCreation = (adapter) => {
|
|
2199
|
+
return typeof adapter?.createDatabaseFromError === "function";
|
|
2200
|
+
};
|
|
2198
2201
|
const supportsDatabaseReset = (adapter) => {
|
|
2199
2202
|
return typeof adapter?.resetDatabase === "function";
|
|
2200
2203
|
};
|
|
@@ -5164,6 +5167,12 @@ Object.defineProperty(exports, 'stripPrismaSchemaModelsAndEnums', {
|
|
|
5164
5167
|
return stripPrismaSchemaModelsAndEnums;
|
|
5165
5168
|
}
|
|
5166
5169
|
});
|
|
5170
|
+
Object.defineProperty(exports, 'supportsDatabaseCreation', {
|
|
5171
|
+
enumerable: true,
|
|
5172
|
+
get: function () {
|
|
5173
|
+
return supportsDatabaseCreation;
|
|
5174
|
+
}
|
|
5175
|
+
});
|
|
5167
5176
|
Object.defineProperty(exports, 'supportsDatabaseMigrationExecution', {
|
|
5168
5177
|
enumerable: true,
|
|
5169
5178
|
get: function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkormx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Modern TypeScript-first ORM for Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
],
|
|
17
17
|
"homepage": "https://arkormx.toneflix.net",
|
|
18
18
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/arkstack-
|
|
19
|
+
"url": "https://github.com/arkstack-tmp/arkormx/issues"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/arkstack-
|
|
23
|
+
"url": "git+https://github.com/arkstack-tmp/arkormx.git"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"author": "3m1n1nce <3m1n1nce@toneflix.net>",
|