@ronin/cli
Advanced tools
Comparing version 0.2.38 to 0.2.39-corny-ron-1099-1-experimental-137
@@ -256,7 +256,8 @@ // src/index.ts | ||
const currentModel = databaseModelsMap.get(model.slug); | ||
if (!(model.name && model.idPrefix)) continue; | ||
if (currentModel && (model.name !== currentModel.name || model.idPrefix !== currentModel.idPrefix)) { | ||
newModels.push( | ||
`alter.model("${model.slug}").to({name: "${model.name}", idPrefix: "${model.idPrefix}"})` | ||
); | ||
if (currentModel) { | ||
if (model.idPrefix && model.idPrefix !== currentModel.idPrefix) { | ||
newModels.push(...createTempModelQuery(model)); | ||
} else if (model.name && model.name !== currentModel.name) { | ||
newModels.push(`alter.model("${model.slug}").to({name: "${model.name}"})`); | ||
} | ||
} | ||
@@ -1185,8 +1186,8 @@ } | ||
]; | ||
var getModelIdentifier = () => { | ||
return `mod_${Array.from(crypto.getRandomValues(new Uint8Array(12))).map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16).toLowerCase()}`; | ||
var getRecordIdentifier = (prefix) => { | ||
return `${prefix}_${Array.from(crypto.getRandomValues(new Uint8Array(12))).map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16).toLowerCase()}`; | ||
}; | ||
var addDefaultModelAttributes = (model, isNew) => { | ||
const copiedModel = { ...model }; | ||
if (isNew && !copiedModel.id) copiedModel.id = getModelIdentifier(); | ||
if (isNew && !copiedModel.id) copiedModel.id = getRecordIdentifier("mod"); | ||
for (const [setting, base, generator, mustRegenerate] of modelAttributes) { | ||
@@ -1481,11 +1482,20 @@ if (!(isNew || mustRegenerate)) continue; | ||
const migrations = fs6.readdirSync(MIGRATIONS_PATH); | ||
const migrationPrompt = migrationFilePath ?? await select3({ | ||
message: "Which migration do you want to apply?", | ||
choices: migrations.sort((a, b) => b.localeCompare(a)).map((migration) => ({ | ||
name: migration, | ||
value: path5.join(MIGRATIONS_PATH, migration) | ||
let migrationPrompt; | ||
if (!flags.apply) { | ||
migrationPrompt = migrationFilePath ?? await select3({ | ||
message: "Which migration do you want to apply?", | ||
choices: migrations.sort((a, b) => b.localeCompare(a)).map((migration) => ({ | ||
name: migration, | ||
value: path5.join(MIGRATIONS_PATH, migration) | ||
})) | ||
}); | ||
} | ||
const protocol = await new Protocol(packages).load(migrationPrompt); | ||
const statements = protocol.getSQLStatements( | ||
existingModels.map((model) => ({ | ||
...model, | ||
// @ts-expect-error This will work once the types are fixed. | ||
fields: convertArrayToObject(model.fields) | ||
})) | ||
}); | ||
const protocol = await new Protocol(packages).load(migrationPrompt); | ||
const statements = protocol.getSQLStatements(existingModels); | ||
); | ||
if (!fs6.existsSync(MIGRATIONS_PATH)) { | ||
@@ -1492,0 +1502,0 @@ fs6.mkdirSync(MIGRATIONS_PATH, { recursive: true }); |
{ | ||
"name": "@ronin/cli", | ||
"version": "0.2.38", | ||
"version": "0.2.39-corny-ron-1099-1-experimental-137", | ||
"type": "module", | ||
@@ -45,3 +45,3 @@ "description": "The command-line interface for RONIN.", | ||
"devDependencies": { | ||
"ronin": "6.2.16", | ||
"ronin": "6.2.20", | ||
"@biomejs/biome": "1.9.4", | ||
@@ -48,0 +48,0 @@ "@types/bun": "1.2.1", |
77319
1886