From 5adc84bc843acf5c1db2357715e79c0b295789f9 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 13 Feb 2025 19:07:35 +0100 Subject: [PATCH] add Project Branding Table --- .../ProjectBranding.ts | 25 +++++++++++++++++++ database/entity/ProjectBranding.ts | 1 + database/entity/index.ts | 2 ++ .../0088-create_project_brandings.ts | 25 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 database/entity/0088-create_project_brandings/ProjectBranding.ts create mode 100644 database/entity/ProjectBranding.ts create mode 100644 database/migrations/0088-create_project_brandings.ts diff --git a/database/entity/0088-create_project_brandings/ProjectBranding.ts b/database/entity/0088-create_project_brandings/ProjectBranding.ts new file mode 100644 index 000000000..9fb53e32b --- /dev/null +++ b/database/entity/0088-create_project_brandings/ProjectBranding.ts @@ -0,0 +1,25 @@ +import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm' + +@Entity('project_brandings') +export class ProjectBranding { + @PrimaryGeneratedColumn() + id: number + + @Column({ name: 'name', type: 'varchar', length: 255 }) + name: string + + @Column({ name: 'alias', type: 'varchar', length: 32 }) + alias: string + + @Column({ name: 'description', type: 'text', nullable: true, default: null }) + description: string | null + + @Column({ name: 'space_id', type: 'int', unsigned: true, nullable: true, default: null }) + spaceId: number | null + + @Column({ name:'new_user_to_space', type: 'tinyint', width: 1, default: 0 }) + newUserToSpace: boolean + + @Column({ name: 'logo_url', type: 'varchar', length: 255, nullable: true, default: null }) + logoUrl: string | null +} diff --git a/database/entity/ProjectBranding.ts b/database/entity/ProjectBranding.ts new file mode 100644 index 000000000..0622d00ef --- /dev/null +++ b/database/entity/ProjectBranding.ts @@ -0,0 +1 @@ +export { ProjectBranding } from './0088-create_project_brandings/ProjectBranding' diff --git a/database/entity/index.ts b/database/entity/index.ts index 3352abdb4..138df80ae 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -2,6 +2,7 @@ import { ContributionLink } from './ContributionLink' import { LoginElopageBuys } from './LoginElopageBuys' import { LoginEmailOptIn } from './LoginEmailOptIn' import { Migration } from './Migration' +import { ProjectBranding } from './ProjectBranding' import { Transaction } from './Transaction' import { TransactionLink } from './TransactionLink' import { User } from './User' @@ -26,6 +27,7 @@ export const entities = [ LoginElopageBuys, LoginEmailOptIn, Migration, + ProjectBranding, PendingTransaction, Transaction, TransactionLink, diff --git a/database/migrations/0088-create_project_brandings.ts b/database/migrations/0088-create_project_brandings.ts new file mode 100644 index 000000000..a741b4fed --- /dev/null +++ b/database/migrations/0088-create_project_brandings.ts @@ -0,0 +1,25 @@ +/* MIGRATION TO CREATE THE project_brandings table + * + * This migration creates the `community` and 'communityfederation' tables in the `apollo` database (`gradido_community`). + */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn(` + CREATE TABLE \`project_brandings\`( + \`id\` INT UNSIGNED NOT NULL AUTO_INCREMENT, + \`name\` VARCHAR(255) NOT NULL, + \`alias\` VARCHAR(32) NOT NULL, + \`description\` TEXT NULL DEFAULT NULL, + \`space_id\` INT UNSIGNED NULL DEFAULT NULL, + \`new_user_to_space\` TINYINT(1) NOT NULL DEFAULT FALSE, + \`logo_url\` VARCHAR(255) NULL DEFAULT NULL, + PRIMARY KEY(\`id\`) + ) ENGINE = InnoDB; + `) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('DROP TABLE `project_brandings`') +}