mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(licenses): add migration and truncation scripts for database management
- Introduced migration script to handle database schema updates using Drizzle ORM. - Added truncation script to clear the database schema and reset the state. - Updated package.json scripts for easier execution of migration and truncation tasks. - Refactored email and Stripe integration for better modularity and maintainability.
This commit is contained in:
22
apps/licenses/migrate.ts
Normal file
22
apps/licenses/migrate.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||
import postgres from "postgres";
|
||||
import "dotenv/config";
|
||||
import * as schema from "./schema";
|
||||
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const sql = postgres(connectionString, { max: 1 });
|
||||
const db = drizzle(sql, { schema });
|
||||
|
||||
await migrate(db, { migrationsFolder: "drizzle" })
|
||||
.then(() => {
|
||||
console.log("Migration complete");
|
||||
sql.end();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Migration failed", error);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => {
|
||||
sql.end();
|
||||
});
|
||||
Reference in New Issue
Block a user