mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-16 17:45:28 +10:00
update database stuff and and package.json to help generate migrations
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import "reflect-metadata"
|
||||
import { DataSource } from "typeorm"
|
||||
import * as env from 'dotenv';
|
||||
import * as path from "path";
|
||||
|
||||
env.config();
|
||||
|
||||
export const AppDataSource = new DataSource({
|
||||
export default new DataSource({
|
||||
type: "postgres",
|
||||
host: "localhost",
|
||||
port: 5432,
|
||||
@@ -12,11 +13,15 @@ export const AppDataSource = new DataSource({
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
database: "postgres",
|
||||
synchronize: false,
|
||||
logging: false,
|
||||
migrations: [__dirname + '/migration/**/*{.js,.ts}'],
|
||||
entities: ["dist/entities/**/*.js"], // Point to compiled JS files
|
||||
subscribers: ["dist/subscribers/**/*.js"],
|
||||
logging: true,
|
||||
entities: [path.join(__dirname, "./entity/*.{ts,js}")],
|
||||
migrations: [path.join(__dirname, "./migrations/*.{ts,js}")],
|
||||
subscribers: ["../subscribers/**/*.{ts, js}"],
|
||||
migrationsRun: true,
|
||||
migrationsTableName: 'migrations',
|
||||
migrationsTransactionMode: 'all'
|
||||
migrationsTransactionMode: 'all',
|
||||
invalidWhereValuesBehavior: {
|
||||
null: "sql-null",
|
||||
undefined: "throw",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { AppDataSource } from "./data-source"
|
||||
import AppDataSource from "./data-source"
|
||||
|
||||
AppDataSource.initialize().then(async () => {
|
||||
|
||||
}).catch(error => console.log(error))
|
||||
AppDataSource.initialize()
|
||||
.then(() => {
|
||||
console.log('✅ Connected successfully');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('❌ Connection failed:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user