@bejibun/database 0.1.14 → 0.1.16
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/commands/make/MakeMigrationCommand.js +3 -8
- package/commands/make/MakeSeederCommand.js +3 -8
- package/package.json +4 -2
- package/stubs/database/migrations/migration_template.ts +13 -0
- package/stubs/database/seeders/seeder_template.ts +5 -0
- /package/{database → stubs/database}/migrations/migration_template.d.ts +0 -0
- /package/{database → stubs/database}/migrations/migration_template.js +0 -0
- /package/{database → stubs/database}/seeders/seeder_template.d.ts +0 -0
- /package/{database → stubs/database}/seeders/seeder_template.js +0 -0
|
@@ -37,13 +37,8 @@ export default class MakeMigrationCommand {
|
|
|
37
37
|
}
|
|
38
38
|
const file = args;
|
|
39
39
|
const migrationsDirectory = "migrations";
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
cwd: migrationsPath
|
|
43
|
-
})).filter(value => (/\.(m?js|ts)$/.test(value) &&
|
|
44
|
-
!value.endsWith(".d.ts")));
|
|
45
|
-
const template = migrations.find(value => value.includes("migration_template"));
|
|
46
|
-
if (isEmpty(template)) {
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${migrationsDirectory}/migration_template.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
47
42
|
Logger.setContext("APP").error("Whoops, something went wrong, the migration template not found.");
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
@@ -61,7 +56,7 @@ export default class MakeMigrationCommand {
|
|
|
61
56
|
}).map((value) => value.count).sort().reverse()[0];
|
|
62
57
|
const counter = defineValue(parseInt(latest), 0);
|
|
63
58
|
const destination = `${migrationsDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
|
|
64
|
-
await Bun.write(App.Path.databasePath(destination), await
|
|
59
|
+
await Bun.write(App.Path.databasePath(destination), await template.text());
|
|
65
60
|
Logger.setContext("APP").info(`Migration [database/${destination}] created successfully.`);
|
|
66
61
|
}
|
|
67
62
|
}
|
|
@@ -37,13 +37,8 @@ export default class MakeSeederCommand {
|
|
|
37
37
|
}
|
|
38
38
|
const file = args;
|
|
39
39
|
const seedersDirectory = "seeders";
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
cwd: seedersPath
|
|
43
|
-
})).filter(value => (/\.(m?js|ts)$/.test(value) &&
|
|
44
|
-
!value.endsWith(".d.ts")));
|
|
45
|
-
const template = seeders.find(value => value.includes("seeder_template"));
|
|
46
|
-
if (isEmpty(template)) {
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${seedersDirectory}/seeder_template.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
47
42
|
Logger.setContext("APP").error("Whoops, something went wrong, the seeder template not found.");
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
@@ -61,7 +56,7 @@ export default class MakeSeederCommand {
|
|
|
61
56
|
}).map((value) => value.count).sort().reverse()[0];
|
|
62
57
|
const counter = defineValue(parseInt(latest), 0);
|
|
63
58
|
const destination = `${seedersDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
|
|
64
|
-
await Bun.write(App.Path.databasePath(destination), await
|
|
59
|
+
await Bun.write(App.Path.databasePath(destination), await template.text());
|
|
65
60
|
Logger.setContext("APP").info(`Seeder [database/${destination}] created successfully.`);
|
|
66
61
|
}
|
|
67
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bejibun/database",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"author": "Havea Crenata <havea.crenata@gmail.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,11 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"alias": "bunx tsc-alias -p tsconfig.json",
|
|
30
|
+
"clean-stubs": "rm -rf stubs",
|
|
31
|
+
"stubs": "cp -rf src/stubs dist",
|
|
30
32
|
"rsync": "rsync -a dist/ ./",
|
|
31
33
|
"clean": "rm -rf dist",
|
|
32
|
-
"build": "bunx tsc -p tsconfig.json && bun run alias && bun run rsync && bun run clean",
|
|
34
|
+
"build": "bun run clean-stubs && bunx tsc -p tsconfig.json && bun run alias && bun run stubs && bun run rsync && bun run clean",
|
|
33
35
|
"deploy": "bun run build && bun publish --access public"
|
|
34
36
|
},
|
|
35
37
|
"type": "module",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type {Knex} from "knex";
|
|
2
|
+
|
|
3
|
+
export function up(knex: Knex): Knex.SchemaBuilder {
|
|
4
|
+
return knex.schema.createTable("tests", (table: Knex.TableBuilder) => {
|
|
5
|
+
table.bigIncrements("id");
|
|
6
|
+
table.timestamps(true, true);
|
|
7
|
+
table.timestamp("deleted_at");
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function down(knex: Knex): Knex.SchemaBuilder {
|
|
12
|
+
return knex.schema.dropTable("tests");
|
|
13
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|