transform migrations to work with mysql, postgres and sqlite
sqlite currently fails syntax of views
This commit is contained in:
parent
2cee8b5119
commit
a73c712626
29 changed files with 1626 additions and 382 deletions
|
@ -1,61 +1,39 @@
|
|||
import { Table, TableForeignKey } from "typeorm";
|
||||
import { getTypeByORM } from "../ormHelper";
|
||||
import { getDefaultByORM, getTypeByORM, isIncrementPrimary, isUUIDPrimary } from "../ormHelper";
|
||||
|
||||
export const calendar_type_table = new Table({
|
||||
name: "calendar_type",
|
||||
columns: [
|
||||
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "type", type: getTypeByORM("varchar"), length: "255", isUnique: true, isNullable: false },
|
||||
{ name: "nscdr", type: getTypeByORM("boolean"), isNullable: false, default: false },
|
||||
{ name: "color", type: getTypeByORM("varchar"), length: "255", isNullable: false },
|
||||
{ name: "passphrase", type: getTypeByORM("varchar"), length: "255", isNullable: true },
|
||||
{ name: "externalPrefix", type: getTypeByORM("varchar"), length: "255", isNullable: false, default: "''" },
|
||||
{ name: "sendToWebpage", type: getTypeByORM("boolean"), isNullable: false, default: false },
|
||||
{ name: "id", ...getTypeByORM("int"), ...isIncrementPrimary },
|
||||
{ name: "type", ...getTypeByORM("varchar"), isUnique: true },
|
||||
{ name: "nscdr", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||
{ name: "color", ...getTypeByORM("varchar") },
|
||||
{ name: "passphrase", ...getTypeByORM("varchar", true) },
|
||||
{ name: "externalPrefix", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||
{ name: "sendToWebpage", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||
],
|
||||
});
|
||||
|
||||
export const calendar_table = new Table({
|
||||
name: "calendar",
|
||||
columns: [
|
||||
{
|
||||
name: "id",
|
||||
type: getTypeByORM("varchar"),
|
||||
length: "36",
|
||||
isPrimary: true,
|
||||
isGenerated: true,
|
||||
generationStrategy: "uuid",
|
||||
},
|
||||
{ name: "starttime", type: getTypeByORM("datetime"), isNullable: false },
|
||||
{ name: "endtime", type: getTypeByORM("datetime"), isNullable: false },
|
||||
{ name: "title", type: getTypeByORM("varchar"), length: "255", isNullable: false },
|
||||
{ name: "content", type: getTypeByORM("text"), isNullable: true },
|
||||
{ name: "allDay", type: getTypeByORM("boolean"), isNullable: false, default: false },
|
||||
{ name: "location", type: getTypeByORM("text"), isNullable: true },
|
||||
{ name: "sequence", type: getTypeByORM("int"), default: 1 },
|
||||
{
|
||||
name: "createdAt",
|
||||
type: getTypeByORM("datetime"),
|
||||
precision: 6,
|
||||
isNullable: false,
|
||||
default: "CURRENT_TIMESTAMP(6)",
|
||||
},
|
||||
{ name: "id", ...getTypeByORM("uuid"), ...isUUIDPrimary },
|
||||
{ name: "starttime", ...getTypeByORM("datetime", false, 6) },
|
||||
{ name: "endtime", ...getTypeByORM("datetime", false, 6) },
|
||||
{ name: "title", ...getTypeByORM("varchar") },
|
||||
{ name: "content", ...getTypeByORM("text", true) },
|
||||
{ name: "allDay", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||
{ name: "location", ...getTypeByORM("text", true) },
|
||||
{ name: "sequence", ...getTypeByORM("int"), default: getDefaultByORM("number", 1) },
|
||||
{ name: "createdAt", ...getTypeByORM("datetime", false, 6), default: getDefaultByORM("currentTimestamp", 6) },
|
||||
{
|
||||
name: "updatedAt",
|
||||
type: getTypeByORM("datetime"),
|
||||
precision: 6,
|
||||
isNullable: false,
|
||||
default: "CURRENT_TIMESTAMP(6)",
|
||||
onUpdate: "CURRENT_TIMESTAMP(6)",
|
||||
...getTypeByORM("datetime", false, 6),
|
||||
default: getDefaultByORM("currentTimestamp", 6),
|
||||
onUpdate: getDefaultByORM<string>("currentTimestamp", 6),
|
||||
},
|
||||
{
|
||||
name: "webpageId",
|
||||
type: getTypeByORM("varchar"),
|
||||
length: "255",
|
||||
isNullable: true,
|
||||
default: null,
|
||||
isUnique: true,
|
||||
},
|
||||
{ name: "typeId", type: getTypeByORM("int"), isNullable: false },
|
||||
{ name: "webpageId", ...getTypeByORM("varchar", true), default: getDefaultByORM("null"), isUnique: true },
|
||||
{ name: "typeId", ...getTypeByORM("int") },
|
||||
],
|
||||
foreignKeys: [
|
||||
new TableForeignKey({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue