transform migrations to work with mysql, postgres and sqlite

sqlite currently fails syntax of views
This commit is contained in:
Julian Krauser 2025-02-01 13:11:10 +01:00
parent 2cee8b5119
commit a73c712626
29 changed files with 1626 additions and 382 deletions

View file

@ -1,17 +1,17 @@
import { Table, TableForeignKey } from "typeorm";
import { getTypeByORM } from "../ormHelper";
import { getDefaultByORM, getTypeByORM, isIncrementPrimary } from "../ormHelper";
export const newsletter_table = new Table({
name: "newsletter",
columns: [
{ name: "id", type: getTypeByORM("int"), isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "title", type: getTypeByORM("varchar"), length: "255" },
{ name: "description", type: getTypeByORM("varchar"), length: "255", default: "''" },
{ name: "newsletterTitle", type: getTypeByORM("varchar"), length: "255", default: "''" },
{ name: "newsletterText", type: getTypeByORM("text"), default: "''" },
{ name: "newsletterSignatur", type: getTypeByORM("varchar"), length: "255", default: "''" },
{ name: "isSent", type: getTypeByORM("boolean"), default: false },
{ name: "recipientsByQueryId", type: getTypeByORM("int"), isNullable: true },
{ name: "id", ...getTypeByORM("int"), ...isIncrementPrimary },
{ name: "title", ...getTypeByORM("varchar") },
{ name: "description", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
{ name: "newsletterTitle", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
{ name: "newsletterText", ...getTypeByORM("text"), default: getDefaultByORM("string") },
{ name: "newsletterSignatur", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
{ name: "isSent", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
{ name: "recipientsByQueryId", ...getTypeByORM("int", true) },
],
foreignKeys: [
new TableForeignKey({
@ -27,10 +27,10 @@ export const newsletter_table = new Table({
export const newsletter_dates_table = new Table({
name: "newsletter_dates",
columns: [
{ name: "newsletterId", type: getTypeByORM("int"), isPrimary: true },
{ name: "calendarId", type: getTypeByORM("varchar"), length: "255", isPrimary: true },
{ name: "diffTitle", type: getTypeByORM("varchar"), length: "255", isNullable: true },
{ name: "diffDescription", type: getTypeByORM("text"), isNullable: true },
{ name: "newsletterId", ...getTypeByORM("int"), isPrimary: true },
{ name: "calendarId", ...getTypeByORM("uuid"), isPrimary: true },
{ name: "diffTitle", ...getTypeByORM("varchar"), isNullable: true },
{ name: "diffDescription", ...getTypeByORM("text", true) },
],
foreignKeys: [
new TableForeignKey({
@ -53,8 +53,8 @@ export const newsletter_dates_table = new Table({
export const newsletter_recipients_table = new Table({
name: "newsletter_recipients",
columns: [
{ name: "newsletterId", type: getTypeByORM("int"), isPrimary: true },
{ name: "memberId", type: getTypeByORM("varchar"), isPrimary: true },
{ name: "newsletterId", ...getTypeByORM("int"), isPrimary: true },
{ name: "memberId", ...getTypeByORM("uuid"), isPrimary: true },
],
foreignKeys: [
new TableForeignKey({
@ -77,8 +77,8 @@ export const newsletter_recipients_table = new Table({
export const newsletter_config_table = new Table({
name: "newsletter_config",
columns: [
{ name: "comTypeId", type: getTypeByORM("int"), isPrimary: true, isNullable: false },
{ name: "config", type: getTypeByORM("varchar"), length: "255", isNullable: false },
{ name: "comTypeId", ...getTypeByORM("int"), isPrimary: true },
{ name: "config", ...getTypeByORM("varchar") },
],
foreignKeys: [
new TableForeignKey({