backup and base schema creation
This commit is contained in:
parent
a91b723f04
commit
b7b6694407
11 changed files with 1030 additions and 46 deletions
|
@ -46,6 +46,7 @@ import { webapiPermission } from "./entity/user/webapi_permission";
|
|||
import { salutation } from "./entity/settings/salutation";
|
||||
|
||||
import { BackupAndResetDatabase1738166124200 } from "./migrations/1738166124200-BackupAndResetDatabase";
|
||||
import { CreateSchema1738166167472 } from "./migrations/1738166167472-CreateSchema";
|
||||
|
||||
const dataSource = new DataSource({
|
||||
type: DB_TYPE as any,
|
||||
|
@ -99,47 +100,10 @@ const dataSource = new DataSource({
|
|||
webapi,
|
||||
webapiPermission,
|
||||
],
|
||||
migrations: [BackupAndResetDatabase1738166124200],
|
||||
migrations: [BackupAndResetDatabase1738166124200, CreateSchema1738166167472],
|
||||
migrationsRun: true,
|
||||
migrationsTransactionMode: "each",
|
||||
subscribers: [],
|
||||
});
|
||||
|
||||
type ORMType = "int" | "bigint" | "boolean" | "date" | "datetime" | "text" | "varchar";
|
||||
function getTypeByORM(type: ORMType): string {
|
||||
const dbType = process.env.DB_TYPE;
|
||||
|
||||
const typeMap: Record<string, Record<ORMType, string>> = {
|
||||
mysql: {
|
||||
int: "int",
|
||||
bigint: "bigint",
|
||||
boolean: "tinyint",
|
||||
date: "date",
|
||||
datetime: "datetime",
|
||||
text: "text",
|
||||
varchar: "varchar",
|
||||
},
|
||||
postgres: {
|
||||
int: "integer",
|
||||
bigint: "bigint",
|
||||
boolean: "boolean",
|
||||
date: "date",
|
||||
datetime: "timestamp",
|
||||
text: "text",
|
||||
varchar: "varchar",
|
||||
},
|
||||
sqlite: {
|
||||
int: "integer",
|
||||
bigint: "integer",
|
||||
boolean: "integer",
|
||||
date: "text",
|
||||
datetime: "text",
|
||||
text: "text",
|
||||
varchar: "text",
|
||||
},
|
||||
};
|
||||
|
||||
return typeMap[dbType]?.[type] || type;
|
||||
}
|
||||
|
||||
export { dataSource, getTypeByORM };
|
||||
export { dataSource };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue