feat: create precious metals by grams and show optional purchase profit
This commit is contained in:
1 parent
027a8c1b6a
commit
0491f515fe
22 files changed
+570
-105
No files matched your search
@@ -5,16 +5,29 @@ const { resolve } = require('node:path');
|
||||
const db = new PrismaClient();
|
||||
(async () => {
|
||||
const tables = await db.$queryRaw`SELECT TABLE_NAME, TABLE_COMMENT FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME <> '_prisma_migrations' ORDER BY TABLE_NAME`;
|
||||
const columns = await db.$queryRaw`SELECT TABLE_NAME, COLUMN_NAME, COLUMN_COMMENT FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME <> '_prisma_migrations' ORDER BY TABLE_NAME, ORDINAL_POSITION`;
|
||||
WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME`;
|
||||
const columns =
|
||||
await db.$queryRaw`SELECT TABLE_NAME, COLUMN_NAME, COLUMN_COMMENT FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME, ORDINAL_POSITION`;
|
||||
if (tables.some((t) => !t.TABLE_COMMENT) || columns.some((c) => !c.COLUMN_COMMENT))
|
||||
throw Error('Application tables or columns are missing comments.');
|
||||
writeFileSync(resolve(__dirname, '../../../docs/database-comments.json'), JSON.stringify({
|
||||
tableCount: tables.length, columnCount: columns.length, tables, columns,
|
||||
}, null, 2) + '\n');
|
||||
throw Error('Database tables or columns are missing comments.');
|
||||
writeFileSync(
|
||||
resolve(__dirname, '../../../docs/database-comments.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
tableCount: tables.length,
|
||||
columnCount: columns.length,
|
||||
tables,
|
||||
columns,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + '\n',
|
||||
);
|
||||
console.log(`Database comments verified: ${tables.length} tables, ${columns.length} columns.`);
|
||||
})().catch(() => {
|
||||
console.error('Comment verification failed. Check database access and table/column comments.');
|
||||
process.exitCode = 1;
|
||||
}).finally(() => db.$disconnect());
|
||||
})()
|
||||
.catch(() => {
|
||||
console.error('Comment verification failed. Check database access and table/column comments.');
|
||||
process.exitCode = 1;
|
||||
})
|
||||
.finally(() => db.$disconnect());
|
||||
Reference in new issue
Block a user