mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Add TypeScript definitions via pg-to-ts and refactor migrations
This commit is contained in:
496
web-app/src/lib/db-schema.ts
Normal file
496
web-app/src/lib/db-schema.ts
Normal file
@@ -0,0 +1,496 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* AUTO-GENERATED FILE - DO NOT EDIT!
|
||||
*
|
||||
* This file was automatically generated by pg-to-ts v.4.1.1
|
||||
* $ pg-to-ts generate -c postgres://username:password@localhost:15432/archtika -t article -t change_log -t collab -t docs_category -t footer -t header -t home -t legal_information -t media -t settings -t user -t website -s internal
|
||||
*
|
||||
*/
|
||||
|
||||
export type Json = unknown;
|
||||
|
||||
// Table article
|
||||
export interface Article {
|
||||
id: string;
|
||||
website_id: string;
|
||||
user_id: string | null;
|
||||
title: string;
|
||||
meta_description: string | null;
|
||||
meta_author: string | null;
|
||||
cover_image: string | null;
|
||||
publication_date: Date | null;
|
||||
main_content: string | null;
|
||||
created_at: Date;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
title_description_search: any | null;
|
||||
category: string | null;
|
||||
article_weight: number | null;
|
||||
}
|
||||
export interface ArticleInput {
|
||||
id?: string;
|
||||
website_id: string;
|
||||
user_id?: string | null;
|
||||
title: string;
|
||||
meta_description?: string | null;
|
||||
meta_author?: string | null;
|
||||
cover_image?: string | null;
|
||||
publication_date?: Date | null;
|
||||
main_content?: string | null;
|
||||
created_at?: Date;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
title_description_search?: any | null;
|
||||
category?: string | null;
|
||||
article_weight?: number | null;
|
||||
}
|
||||
const article = {
|
||||
tableName: "article",
|
||||
columns: [
|
||||
"id",
|
||||
"website_id",
|
||||
"user_id",
|
||||
"title",
|
||||
"meta_description",
|
||||
"meta_author",
|
||||
"cover_image",
|
||||
"publication_date",
|
||||
"main_content",
|
||||
"created_at",
|
||||
"last_modified_at",
|
||||
"last_modified_by",
|
||||
"title_description_search",
|
||||
"category",
|
||||
"article_weight"
|
||||
],
|
||||
requiredForInsert: ["website_id", "title"],
|
||||
primaryKey: "id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User },
|
||||
cover_image: { table: "media", column: "id", $type: null as unknown as Media },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User },
|
||||
category: { table: "docs_category", column: "id", $type: null as unknown as DocsCategory }
|
||||
},
|
||||
$type: null as unknown as Article,
|
||||
$input: null as unknown as ArticleInput
|
||||
} as const;
|
||||
|
||||
// Table change_log
|
||||
export interface ChangeLog {
|
||||
website_id: string;
|
||||
user_id: string;
|
||||
change_summary: string;
|
||||
previous_value: Json | null;
|
||||
new_value: Json | null;
|
||||
timestamp: Date;
|
||||
}
|
||||
export interface ChangeLogInput {
|
||||
website_id: string;
|
||||
user_id?: string;
|
||||
change_summary: string;
|
||||
previous_value?: Json | null;
|
||||
new_value?: Json | null;
|
||||
timestamp?: Date;
|
||||
}
|
||||
const change_log = {
|
||||
tableName: "change_log",
|
||||
columns: ["website_id", "user_id", "change_summary", "previous_value", "new_value", "timestamp"],
|
||||
requiredForInsert: ["website_id", "change_summary"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as ChangeLog,
|
||||
$input: null as unknown as ChangeLogInput
|
||||
} as const;
|
||||
|
||||
// Table collab
|
||||
export interface Collab {
|
||||
website_id: string;
|
||||
user_id: string;
|
||||
permission_level: number;
|
||||
added_at: Date;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface CollabInput {
|
||||
website_id: string;
|
||||
user_id: string;
|
||||
permission_level?: number;
|
||||
added_at?: Date;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const collab = {
|
||||
tableName: "collab",
|
||||
columns: [
|
||||
"website_id",
|
||||
"user_id",
|
||||
"permission_level",
|
||||
"added_at",
|
||||
"last_modified_at",
|
||||
"last_modified_by"
|
||||
],
|
||||
requiredForInsert: ["website_id", "user_id"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Collab,
|
||||
$input: null as unknown as CollabInput
|
||||
} as const;
|
||||
|
||||
// Table docs_category
|
||||
export interface DocsCategory {
|
||||
id: string;
|
||||
website_id: string;
|
||||
user_id: string | null;
|
||||
category_name: string;
|
||||
category_weight: number;
|
||||
}
|
||||
export interface DocsCategoryInput {
|
||||
id?: string;
|
||||
website_id: string;
|
||||
user_id?: string | null;
|
||||
category_name: string;
|
||||
category_weight: number;
|
||||
}
|
||||
const docs_category = {
|
||||
tableName: "docs_category",
|
||||
columns: ["id", "website_id", "user_id", "category_name", "category_weight"],
|
||||
requiredForInsert: ["website_id", "category_name", "category_weight"],
|
||||
primaryKey: "id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as DocsCategory,
|
||||
$input: null as unknown as DocsCategoryInput
|
||||
} as const;
|
||||
|
||||
// Table footer
|
||||
export interface Footer {
|
||||
website_id: string;
|
||||
additional_text: string;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface FooterInput {
|
||||
website_id: string;
|
||||
additional_text: string;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const footer = {
|
||||
tableName: "footer",
|
||||
columns: ["website_id", "additional_text", "last_modified_at", "last_modified_by"],
|
||||
requiredForInsert: ["website_id", "additional_text"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Footer,
|
||||
$input: null as unknown as FooterInput
|
||||
} as const;
|
||||
|
||||
// Table header
|
||||
export interface Header {
|
||||
website_id: string;
|
||||
logo_type: string;
|
||||
logo_text: string | null;
|
||||
logo_image: string | null;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface HeaderInput {
|
||||
website_id: string;
|
||||
logo_type?: string;
|
||||
logo_text?: string | null;
|
||||
logo_image?: string | null;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const header = {
|
||||
tableName: "header",
|
||||
columns: [
|
||||
"website_id",
|
||||
"logo_type",
|
||||
"logo_text",
|
||||
"logo_image",
|
||||
"last_modified_at",
|
||||
"last_modified_by"
|
||||
],
|
||||
requiredForInsert: ["website_id"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
logo_image: { table: "media", column: "id", $type: null as unknown as Media },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Header,
|
||||
$input: null as unknown as HeaderInput
|
||||
} as const;
|
||||
|
||||
// Table home
|
||||
export interface Home {
|
||||
website_id: string;
|
||||
main_content: string;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface HomeInput {
|
||||
website_id: string;
|
||||
main_content: string;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const home = {
|
||||
tableName: "home",
|
||||
columns: ["website_id", "main_content", "last_modified_at", "last_modified_by"],
|
||||
requiredForInsert: ["website_id", "main_content"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Home,
|
||||
$input: null as unknown as HomeInput
|
||||
} as const;
|
||||
|
||||
// Table legal_information
|
||||
export interface LegalInformation {
|
||||
website_id: string;
|
||||
main_content: string;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface LegalInformationInput {
|
||||
website_id: string;
|
||||
main_content: string;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const legal_information = {
|
||||
tableName: "legal_information",
|
||||
columns: ["website_id", "main_content", "last_modified_at", "last_modified_by"],
|
||||
requiredForInsert: ["website_id", "main_content"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as LegalInformation,
|
||||
$input: null as unknown as LegalInformationInput
|
||||
} as const;
|
||||
|
||||
// Table media
|
||||
export interface Media {
|
||||
id: string;
|
||||
website_id: string;
|
||||
user_id: string;
|
||||
blob: string;
|
||||
mimetype: string;
|
||||
original_name: string;
|
||||
created_at: Date;
|
||||
}
|
||||
export interface MediaInput {
|
||||
id?: string;
|
||||
website_id: string;
|
||||
user_id?: string;
|
||||
blob: string;
|
||||
mimetype: string;
|
||||
original_name: string;
|
||||
created_at?: Date;
|
||||
}
|
||||
const media = {
|
||||
tableName: "media",
|
||||
columns: ["id", "website_id", "user_id", "blob", "mimetype", "original_name", "created_at"],
|
||||
requiredForInsert: ["website_id", "blob", "mimetype", "original_name"],
|
||||
primaryKey: "id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Media,
|
||||
$input: null as unknown as MediaInput
|
||||
} as const;
|
||||
|
||||
// Table settings
|
||||
export interface Settings {
|
||||
website_id: string;
|
||||
accent_color_light_theme: string;
|
||||
accent_color_dark_theme: string;
|
||||
favicon_image: string | null;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
}
|
||||
export interface SettingsInput {
|
||||
website_id: string;
|
||||
accent_color_light_theme?: string;
|
||||
accent_color_dark_theme?: string;
|
||||
favicon_image?: string | null;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
}
|
||||
const settings = {
|
||||
tableName: "settings",
|
||||
columns: [
|
||||
"website_id",
|
||||
"accent_color_light_theme",
|
||||
"accent_color_dark_theme",
|
||||
"favicon_image",
|
||||
"last_modified_at",
|
||||
"last_modified_by"
|
||||
],
|
||||
requiredForInsert: ["website_id"],
|
||||
primaryKey: "website_id",
|
||||
foreignKeys: {
|
||||
website_id: { table: "website", column: "id", $type: null as unknown as Website },
|
||||
favicon_image: { table: "media", column: "id", $type: null as unknown as Media },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Settings,
|
||||
$input: null as unknown as SettingsInput
|
||||
} as const;
|
||||
|
||||
// Table user
|
||||
export interface User {
|
||||
id: string;
|
||||
username: string;
|
||||
password_hash: string;
|
||||
role: string;
|
||||
}
|
||||
export interface UserInput {
|
||||
id?: string;
|
||||
username: string;
|
||||
password_hash: string;
|
||||
role?: string;
|
||||
}
|
||||
const user = {
|
||||
tableName: "user",
|
||||
columns: ["id", "username", "password_hash", "role"],
|
||||
requiredForInsert: ["username", "password_hash"],
|
||||
primaryKey: "id",
|
||||
foreignKeys: {},
|
||||
$type: null as unknown as User,
|
||||
$input: null as unknown as UserInput
|
||||
} as const;
|
||||
|
||||
// Table website
|
||||
export interface Website {
|
||||
id: string;
|
||||
user_id: string;
|
||||
content_type: string;
|
||||
title: string;
|
||||
created_at: Date;
|
||||
last_modified_at: Date;
|
||||
last_modified_by: string | null;
|
||||
title_search: any | null;
|
||||
is_published: boolean;
|
||||
}
|
||||
export interface WebsiteInput {
|
||||
id?: string;
|
||||
user_id?: string;
|
||||
content_type: string;
|
||||
title: string;
|
||||
created_at?: Date;
|
||||
last_modified_at?: Date;
|
||||
last_modified_by?: string | null;
|
||||
title_search?: any | null;
|
||||
is_published?: boolean;
|
||||
}
|
||||
const website = {
|
||||
tableName: "website",
|
||||
columns: [
|
||||
"id",
|
||||
"user_id",
|
||||
"content_type",
|
||||
"title",
|
||||
"created_at",
|
||||
"last_modified_at",
|
||||
"last_modified_by",
|
||||
"title_search",
|
||||
"is_published"
|
||||
],
|
||||
requiredForInsert: ["content_type", "title"],
|
||||
primaryKey: "id",
|
||||
foreignKeys: {
|
||||
user_id: { table: "user", column: "id", $type: null as unknown as User },
|
||||
last_modified_by: { table: "user", column: "id", $type: null as unknown as User }
|
||||
},
|
||||
$type: null as unknown as Website,
|
||||
$input: null as unknown as WebsiteInput
|
||||
} as const;
|
||||
|
||||
export interface TableTypes {
|
||||
article: {
|
||||
select: Article;
|
||||
input: ArticleInput;
|
||||
};
|
||||
change_log: {
|
||||
select: ChangeLog;
|
||||
input: ChangeLogInput;
|
||||
};
|
||||
collab: {
|
||||
select: Collab;
|
||||
input: CollabInput;
|
||||
};
|
||||
docs_category: {
|
||||
select: DocsCategory;
|
||||
input: DocsCategoryInput;
|
||||
};
|
||||
footer: {
|
||||
select: Footer;
|
||||
input: FooterInput;
|
||||
};
|
||||
header: {
|
||||
select: Header;
|
||||
input: HeaderInput;
|
||||
};
|
||||
home: {
|
||||
select: Home;
|
||||
input: HomeInput;
|
||||
};
|
||||
legal_information: {
|
||||
select: LegalInformation;
|
||||
input: LegalInformationInput;
|
||||
};
|
||||
media: {
|
||||
select: Media;
|
||||
input: MediaInput;
|
||||
};
|
||||
settings: {
|
||||
select: Settings;
|
||||
input: SettingsInput;
|
||||
};
|
||||
user: {
|
||||
select: User;
|
||||
input: UserInput;
|
||||
};
|
||||
website: {
|
||||
select: Website;
|
||||
input: WebsiteInput;
|
||||
};
|
||||
}
|
||||
|
||||
export const tables = {
|
||||
article,
|
||||
change_log,
|
||||
collab,
|
||||
docs_category,
|
||||
footer,
|
||||
header,
|
||||
home,
|
||||
legal_information,
|
||||
media,
|
||||
settings,
|
||||
user,
|
||||
website
|
||||
};
|
||||
Reference in New Issue
Block a user