@package-broker/adapter-node 0.4.0 → 0.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@package-broker/adapter-node",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "scripts": {
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Database Migration Script
5
+ * Runs Drizzle migrations for SQLite database
6
+ *
7
+ * Usage:
8
+ * node scripts/migrate.js <db_path> [migrations_path]
9
+ *
10
+ * Example:
11
+ * node scripts/migrate.js /data/database.sqlite
12
+ * node scripts/migrate.js /data/database.sqlite /app/packages/main/migrations
13
+ */
14
+
15
+ const { SqliteDriver } = require('../dist/drivers/sqlite-driver.cjs');
16
+ const path = require('path');
17
+
18
+ const dbPath = process.argv[2];
19
+ const migrationsPath = process.argv[3] || 'packages/main/migrations';
20
+
21
+ if (!dbPath) {
22
+ console.error('❌ Error: Database path is required');
23
+ console.error('Usage: node scripts/migrate.js <db_path> [migrations_path]');
24
+ process.exit(1);
25
+ }
26
+
27
+ async function runMigrations() {
28
+ try {
29
+ console.log(`Initializing database at: ${dbPath}`);
30
+ const driver = new SqliteDriver(dbPath);
31
+
32
+ const absoluteMigrationsPath = path.isAbsolute(migrationsPath)
33
+ ? migrationsPath
34
+ : path.join(process.cwd(), migrationsPath);
35
+
36
+ console.log(`Running migrations from: ${absoluteMigrationsPath}`);
37
+ await driver.runMigrations(absoluteMigrationsPath);
38
+
39
+ console.log('✅ Database migrations completed successfully');
40
+ process.exit(0);
41
+ } catch (error) {
42
+ console.error('❌ Migration failed:', error.message);
43
+ console.error(error.stack);
44
+ process.exit(1);
45
+ }
46
+ }
47
+
48
+ runMigrations();