First Commit

This commit is contained in:
2026-09-12 13:56:36 +01:00
commit 4d75af0418
426 changed files with 36452 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
import { MediaParadigms, MediaTypes } from "@/src/dict/media-dict";
import { UserTypes } from "@/src/dict/user-types-dict";
import type { BUN_SQLITE_DatabaseSchemaType } from "@moduletrace/bun-sqlite/dist/types";
const schema: BUN_SQLITE_DatabaseSchemaType = {
tables: [
{
tableName: "users",
fields: [
{
fieldName: "first_name",
dataType: "TEXT",
},
{
fieldName: "last_name",
dataType: "TEXT",
},
{
fieldName: "email",
dataType: "TEXT",
unique: true,
},
{
fieldName: "username",
dataType: "TEXT",
unique: true,
},
{
fieldName: "password",
dataType: "TEXT",
},
{
fieldName: "bio",
dataType: "TEXT",
html: true,
},
{
fieldName: "archived",
dataType: "INTEGER",
options: [0, 1],
defaultValue: 0,
},
],
},
{
tableName: "user_types",
fields: [
{
fieldName: "user_id",
dataType: "INTEGER",
},
{
fieldName: "user_type",
dataType: "TEXT",
options: UserTypes.map((ut) => ut.value),
},
],
},
{
tableName: "sso_login_codes",
fields: [
{
fieldName: "user_id",
dataType: "INTEGER",
unique: true,
},
{
fieldName: "code",
dataType: "TEXT",
},
],
},
{
tableName: "media",
fields: [
{
fieldName: "user_id",
dataType: "INTEGER",
},
{
fieldName: "title",
dataType: "TEXT",
},
{
fieldName: "description",
dataType: "TEXT",
},
{
fieldName: "summary",
dataType: "TEXT",
},
{
fieldName: "media_type",
dataType: "TEXT",
options: MediaTypes.map((it) => it.value),
},
{
fieldName: "media_write_path",
dataType: "TEXT",
},
{
fieldName: "media_thumbnail_write_path",
dataType: "TEXT",
},
{
fieldName: "mime_type",
dataType: "TEXT",
},
{
fieldName: "text_content",
dataType: "TEXT",
},
{
fieldName: "is_primary",
dataType: "INTEGER",
options: [0, 1],
},
{
fieldName: "is_rag_ingested",
dataType: "INTEGER",
options: [0, 1],
},
{
fieldName: "is_private",
dataType: "INTEGER",
options: [0, 1],
},
{
fieldName: "archived",
dataType: "INTEGER",
options: [0, 1],
},
],
uniqueConstraints: [
{
alias: "one_user_per_primary_profile_image",
constraintName: "One User per primary profile image",
constraintTableFields: [
{ value: "user_id" },
{ value: "is_primary" },
],
},
],
},
{
tableName: "media_paradigms",
fields: [
{
fieldName: "media_id",
dataType: "INTEGER",
foreignKey: {
cascadeDelete: true,
destinationTableName: "media",
destinationTableColumnName: "id",
destinationTableColumnType: "INTEGER",
foreignKeyName: "media_paradigm_media_fk",
},
},
{
fieldName: "media_paradigm",
dataType: "TEXT",
options: MediaParadigms.map((mp) => mp.value),
},
],
},
],
};
export default schema;