You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1017 B

const path = require('path');
// 根据环境选择迁移文件目录
// 开发模式使用 TypeScript 源文件(通过 tsx 运行)
// 生产模式使用编译后的 JavaScript 文件
const migrationsDir = process.env.NODE_ENV === 'production'
? path.join(__dirname, 'dist/migrations')
: path.join(__dirname, 'src/migrations');
module.exports = {
development: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, './database/dev.sqlite3')
},
migrations: {
directory: migrationsDir
},
useNullAsDefault: true,
pool: {
afterCreate: (conn, cb) => {
conn.run('PRAGMA foreign_keys = ON', cb);
}
}
},
production: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, './database/prod.sqlite3')
},
migrations: {
directory: migrationsDir
},
useNullAsDefault: true,
pool: {
afterCreate: (conn, cb) => {
conn.run('PRAGMA foreign_keys = ON', cb);
}
}
}
};