storemw-core-api 1.0.172 → 1.0.173
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/scripts/migrate.d.ts +1 -0
- package/dist/scripts/migrate.js +42 -0
- package/dist/scripts/migrate.js.map +1 -0
- package/dist/scripts/migrate_core.d.ts +1 -0
- package/dist/scripts/migrate_core.js +41 -0
- package/dist/scripts/migrate_core.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +783 -2935
- package/prisma/unuse/schema.prisma +3141 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
+
// read --env flag from args, default to development
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
const envFlag = args.find(a => a.startsWith('--env='));
|
|
13
|
+
const envName = envFlag ? envFlag.split('=')[1] : 'development';
|
|
14
|
+
const envFile = path_1.default.resolve(process.cwd(), `.env.${envName}`);
|
|
15
|
+
if (!fs_1.default.existsSync(envFile)) {
|
|
16
|
+
console.error(`❌ ${envFile} not found`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
dotenv_1.default.config({ path: envFile });
|
|
20
|
+
if (!process.env.DATABASE_URL) {
|
|
21
|
+
console.error(`❌ DATABASE_URL is not set in .env.${envName}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
console.log(`🔧 Using environment: ${envName}`);
|
|
25
|
+
console.log(`🔧 Loaded: .env.${envName}`);
|
|
26
|
+
const corePrismaSchema = path_1.default.resolve(__dirname, '../../prisma/schema.prisma');
|
|
27
|
+
const consumerMigrationsDir = path_1.default.resolve(process.cwd(), 'prisma/migrations');
|
|
28
|
+
const consumerSchemaDir = path_1.default.resolve(process.cwd(), 'prisma');
|
|
29
|
+
// 1. ensure consumer prisma folder exists
|
|
30
|
+
fs_1.default.mkdirSync(consumerSchemaDir, { recursive: true });
|
|
31
|
+
fs_1.default.mkdirSync(consumerMigrationsDir, { recursive: true });
|
|
32
|
+
// 2. copy core schema.prisma into consumer prisma folder
|
|
33
|
+
const tempSchema = path_1.default.resolve(consumerSchemaDir, 'schema.prisma');
|
|
34
|
+
fs_1.default.copyFileSync(corePrismaSchema, tempSchema);
|
|
35
|
+
// 3. run prisma migrate dev
|
|
36
|
+
(0, child_process_1.execSync)('npx prisma migrate dev --name init_core', {
|
|
37
|
+
stdio: 'inherit',
|
|
38
|
+
cwd: process.cwd(),
|
|
39
|
+
env: { ...process.env }
|
|
40
|
+
});
|
|
41
|
+
console.log('✅ Core migration generated successfully');
|
|
42
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/scripts/migrate.ts"],"names":[],"mappings":";;;;;AAAA,iDAAwC;AACxC,gDAAuB;AACvB,4CAAmB;AACnB,oDAA2B;AAE3B,oDAAoD;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAA;AAE/D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,CAAC,CAAA;AACnE,YAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;AAE7C,4BAA4B;AAC5B,IAAA,wBAAQ,EAAC,yCAAyC,EAAE;IAChD,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;CAC1B,CAAC,CAAA;AAEF,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA","sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\nimport dotenv from 'dotenv'\n\n// read --env flag from args, default to development\nconst args = process.argv.slice(2)\nconst envFlag = args.find(a => a.startsWith('--env='))\nconst envName = envFlag ? envFlag.split('=')[1] : 'development'\n\nconst envFile = path.resolve(process.cwd(), `.env.${envName}`)\n\nif (!fs.existsSync(envFile)) {\n console.error(`❌ ${envFile} not found`)\n process.exit(1)\n}\n\ndotenv.config({ path: envFile })\n\nif (!process.env.DATABASE_URL) {\n console.error(`❌ DATABASE_URL is not set in .env.${envName}`)\n process.exit(1)\n}\n\nconsole.log(`🔧 Using environment: ${envName}`)\nconsole.log(`🔧 Loaded: .env.${envName}`)\n\nconst corePrismaSchema = path.resolve(\n __dirname, '../../prisma/schema.prisma'\n)\n\nconst consumerMigrationsDir = path.resolve(\n process.cwd(), 'prisma/migrations'\n)\n\nconst consumerSchemaDir = path.resolve(\n process.cwd(), 'prisma'\n)\n\n// 1. ensure consumer prisma folder exists\nfs.mkdirSync(consumerSchemaDir, { recursive: true })\nfs.mkdirSync(consumerMigrationsDir, { recursive: true })\n\n// 2. copy core schema.prisma into consumer prisma folder\nconst tempSchema = path.resolve(consumerSchemaDir, 'schema.prisma')\nfs.copyFileSync(corePrismaSchema, tempSchema)\n\n// 3. run prisma migrate dev\nexecSync('npx prisma migrate dev --name init_core', {\n stdio: 'inherit',\n cwd: process.cwd(),\n env: { ...process.env }\n})\n\nconsole.log('✅ Core migration generated successfully')"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const corePrismaSchema = path_1.default.resolve(__dirname, '../../prisma/schema.prisma');
|
|
10
|
+
const migrationDir = path_1.default.resolve(process.cwd(), 'prisma/migrations');
|
|
11
|
+
// generate datetime string e.g. 20240101_120000
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const datetime = now.getFullYear().toString() +
|
|
14
|
+
String(now.getMonth() + 1).padStart(2, '0') +
|
|
15
|
+
String(now.getDate()).padStart(2, '0') +
|
|
16
|
+
'_' +
|
|
17
|
+
String(now.getHours()).padStart(2, '0') +
|
|
18
|
+
String(now.getMinutes()).padStart(2, '0') +
|
|
19
|
+
String(now.getSeconds()).padStart(2, '0');
|
|
20
|
+
const fileName = `migration_core-${datetime}.sql`;
|
|
21
|
+
const migrationFile = path_1.default.resolve(migrationDir, fileName);
|
|
22
|
+
// 1. create migrations folder
|
|
23
|
+
fs_1.default.mkdirSync(migrationDir, { recursive: true });
|
|
24
|
+
// 2. generate SQL from core schema — no DB needed
|
|
25
|
+
(0, child_process_1.execSync)(`npx prisma migrate diff --from-empty --to-schema-datamodel "${corePrismaSchema}" --script > "${migrationFile}"`, {
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
cwd: process.cwd(),
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
DATABASE_URL: 'postgresql://dummy:dummy@localhost:5432/dummy'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
console.log(`✅ Core migration SQL generated at:`);
|
|
34
|
+
console.log(` prisma/migrations/${fileName}`);
|
|
35
|
+
console.log('');
|
|
36
|
+
console.log('👉 Next steps:');
|
|
37
|
+
console.log(' 1. Run the SQL against your database');
|
|
38
|
+
console.log(' 2. Add your own tables');
|
|
39
|
+
console.log(' 3. Run: npx prisma db pull');
|
|
40
|
+
console.log(' 4. Run: npx prisma generate');
|
|
41
|
+
//# sourceMappingURL=migrate_core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_core.js","sourceRoot":"","sources":["../../src/scripts/migrate_core.ts"],"names":[],"mappings":";;;;;AAAA,iDAAwC;AACxC,gDAAuB;AACvB,4CAAmB;AAEnB,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CACjC,SAAS,EAAE,4BAA4B,CAC1C,CAAA;AAED,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAC7B,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CACrC,CAAA;AAED,gDAAgD;AAChD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;AACtB,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IACzC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IACtC,GAAG;IACH,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IACvC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAE7C,MAAM,QAAQ,GAAG,kBAAkB,QAAQ,MAAM,CAAA;AACjD,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;AAE1D,8BAA8B;AAC9B,YAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAE/C,kDAAkD;AAClD,IAAA,wBAAQ,EACJ,+DAA+D,gBAAgB,iBAAiB,aAAa,GAAG,EAChH;IACI,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE;QACD,GAAG,OAAO,CAAC,GAAG;QACd,YAAY,EAAE,+CAA+C;KAChE;CACJ,CACJ,CAAA;AAED,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;AACjD,OAAO,CAAC,GAAG,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAA;AAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACf,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;AAC7B,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA;AACtD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AACxC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;AAC5C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA","sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\n\nconst corePrismaSchema = path.resolve(\n __dirname, '../../prisma/schema.prisma'\n)\n\nconst migrationDir = path.resolve(\n process.cwd(), 'prisma/migrations'\n)\n\n// generate datetime string e.g. 20240101_120000\nconst now = new Date()\nconst datetime = now.getFullYear().toString() +\n String(now.getMonth() + 1).padStart(2, '0') +\n String(now.getDate()).padStart(2, '0') +\n '_' +\n String(now.getHours()).padStart(2, '0') +\n String(now.getMinutes()).padStart(2, '0') +\n String(now.getSeconds()).padStart(2, '0')\n\nconst fileName = `migration_core-${datetime}.sql`\nconst migrationFile = path.resolve(migrationDir, fileName)\n\n// 1. create migrations folder\nfs.mkdirSync(migrationDir, { recursive: true })\n\n// 2. generate SQL from core schema — no DB needed\nexecSync(\n `npx prisma migrate diff --from-empty --to-schema-datamodel \"${corePrismaSchema}\" --script > \"${migrationFile}\"`,\n {\n stdio: 'inherit',\n cwd: process.cwd(),\n env: {\n ...process.env,\n DATABASE_URL: 'postgresql://dummy:dummy@localhost:5432/dummy'\n }\n }\n)\n\nconsole.log(`✅ Core migration SQL generated at:`)\nconsole.log(` prisma/migrations/${fileName}`)\nconsole.log('')\nconsole.log('👉 Next steps:')\nconsole.log(' 1. Run the SQL against your database')\nconsole.log(' 2. Add your own tables')\nconsole.log(' 3. Run: npx prisma db pull')\nconsole.log(' 4. Run: npx prisma generate')"]}
|