Schema Changes

This commit is contained in:
2025-12-06 19:29:28 +01:00
parent 63af22b671
commit 7450f90a0f
7 changed files with 55 additions and 55 deletions

View File

@@ -14,67 +14,67 @@ import { authUsers } from "./auth_users"
export const authProfiles = pgTable("auth_profiles", { export const authProfiles = pgTable("auth_profiles", {
id: uuid("id").primaryKey().defaultRandom(), id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id").references(() => authUsers.id), user_id: uuid("user_id").references(() => authUsers.id),
tenantId: bigint("tenant_id", { mode: "number" }).notNull(), tenant_id: bigint("tenant_id", { mode: "number" }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
firstName: text("first_name").notNull(), first_name: text("first_name").notNull(),
lastName: text("last_name").notNull(), last_name: text("last_name").notNull(),
fullName: text("full_name").generatedAlwaysAs( full_name: text("full_name").generatedAlwaysAs(
`((first_name || ' ') || last_name)` `((first_name || ' ') || last_name)`
), ),
mobileTel: text("mobile_tel"), mobile_tel: text("mobile_tel"),
fixedTel: text("fixed_tel"), fixed_tel: text("fixed_tel"),
salutation: text("salutation"), salutation: text("salutation"),
employeeNumber: text("employee_number"), employee_number: text("employee_number"),
weeklyWorkingHours: doublePrecision("weekly_working_hours").default(0), weekly_working_hours: doublePrecision("weekly_working_hours").default(0),
annualPaidLeaveDays: bigint("annual_paid_leave_days", { mode: "number" }), annual_paid_leave_days: bigint("annual_paid_leave_days", { mode: "number" }),
weeklyRegularWorkingHours: jsonb("weekly_regular_working_hours").default("{}"), weekly_regular_working_hours: jsonb("weekly_regular_working_hours").default("{}"),
clothingSizeTop: text("clothing_size_top"), clothing_size_top: text("clothing_size_top"),
clothingSizeBottom: text("clothing_size_bottom"), clothing_size_bottom: text("clothing_size_bottom"),
clothingSizeShoe: text("clothing_size_shoe"), clothing_size_shoe: text("clothing_size_shoe"),
emailSignature: text("email_signature").default("<p>Mit freundlichen Grüßen</p>"), email_signature: text("email_signature").default("<p>Mit freundlichen Grüßen</p>"),
birthday: date("birthday"), birthday: date("birthday"),
entryDate: date("entry_date").defaultNow(), entry_date: date("entry_date").defaultNow(),
automaticHourCorrections: jsonb("automatic_hour_corrections").default("[]"), automatic_hour_corrections: jsonb("automatic_hour_corrections").default("[]"),
recreationDaysCompensation: boolean("recreation_days_compensation") recreation_days_compensation: boolean("recreation_days_compensation")
.notNull() .notNull()
.default(true), .default(true),
customerForPortal: bigint("customer_for_portal", { mode: "number" }), customer_for_portal: bigint("customer_for_portal", { mode: "number" }),
pinnedOnNavigation: jsonb("pinned_on_navigation").notNull().default("[]"), pinned_on_navigation: jsonb("pinned_on_navigation").notNull().default("[]"),
email: text("email"), email: text("email"),
tokenId: text("token_id"), token_id: text("token_id"),
weeklyWorkingDays: doublePrecision("weekly_working_days"), weekly_working_days: doublePrecision("weekly_working_days"),
oldProfileId: uuid("old_profile_id"), old_profile_id: uuid("old_profile_id"),
tempConfig: jsonb("temp_config"), temp_config: jsonb("temp_config"),
stateCode: text("state_code").default("DE-NI"), state_code: text("state_code").default("DE-NI"),
contractType: text("contract_type"), contract_type: text("contract_type"),
position: text("position"), position: text("position"),
qualification: text("qualification"), qualification: text("qualification"),
addressStreet: text("address_street"), address_street: text("address_street"),
addressZip: text("address_zip"), address_zip: text("address_zip"),
addressCity: text("address_city"), address_city: text("address_city"),
active: boolean("active").notNull().default(true), active: boolean("active").notNull().default(true),
}) })

View File

@@ -4,18 +4,18 @@ import { authRoles } from "./auth_roles"
export const authRolePermissions = pgTable( export const authRolePermissions = pgTable(
"auth_role_permissions", "auth_role_permissions",
{ {
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
roleId: uuid("role_id") role_id: uuid("role_id")
.notNull() .notNull()
.references(() => authRoles.id), .references(() => authRoles.id),
permission: text("permission").notNull(), permission: text("permission").notNull(),
}, },
(table) => ({ (table) => ({
primaryKey: [table.roleId, table.permission], primaryKey: [table.role_id, table.permission],
}) })
) )

View File

@@ -4,15 +4,15 @@ import { authUsers } from "./auth_users"
export const authRoles = pgTable("auth_roles", { export const authRoles = pgTable("auth_roles", {
id: uuid("id").primaryKey().defaultRandom(), id: uuid("id").primaryKey().defaultRandom(),
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
name: text("name").notNull(), name: text("name").notNull(),
description: text("description"), description: text("description"),
createdBy: uuid("created_by").references(() => authUsers.id), created_by: uuid("created_by").references(() => authUsers.id),
tenantId: bigint("tenant_id", {mode: "number"}), tenant_id: bigint("tenant_id", {mode: "number"}),
}) })
export type AuthRole = typeof authRoles.$inferSelect export type AuthRole = typeof authRoles.$inferSelect

View File

@@ -4,17 +4,17 @@ import { authUsers } from "./auth_users"
export const authTenantUsers = pgTable( export const authTenantUsers = pgTable(
"auth_tenant_users", "auth_tenant_users",
{ {
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
tenantId: bigint("tenant_id", { mode: "number" }).notNull(), tenant_id: bigint("tenant_id", { mode: "number" }).notNull(),
userId: uuid("user_id").notNull(), user_id: uuid("user_id").notNull(),
createdBy: uuid("created_by").references(() => authUsers.id), created_by: uuid("created_by").references(() => authUsers.id),
}, },
(table) => ({ (table) => ({
primaryKey: [table.tenantId, table.userId], primaryKey: [table.tenant_id, table.user_id],
}) })
) )

View File

@@ -5,24 +5,24 @@ import { authRoles } from "./auth_roles"
export const authUserRoles = pgTable( export const authUserRoles = pgTable(
"auth_user_roles", "auth_user_roles",
{ {
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
userId: uuid("user_id") user_id: uuid("user_id")
.notNull() .notNull()
.references(() => authUsers.id), .references(() => authUsers.id),
roleId: uuid("role_id") role_id: uuid("role_id")
.notNull() .notNull()
.references(() => authRoles.id), .references(() => authRoles.id),
tenantId: bigint("tenant_id", { mode: "number" }).notNull(), tenant_id: bigint("tenant_id", { mode: "number" }).notNull(),
createdBy: uuid("created_by").references(() => authUsers.id), created_by: uuid("created_by").references(() => authUsers.id),
}, },
(table) => ({ (table) => ({
primaryKey: [table.userId, table.roleId, table.tenantId], primaryKey: [table.user_id, table.role_id, table.tenant_id],
}) })
) )

View File

@@ -3,7 +3,7 @@ import { pgTable, uuid, text, boolean, timestamp } from "drizzle-orm/pg-core"
export const authUsers = pgTable("auth_users", { export const authUsers = pgTable("auth_users", {
id: uuid("id").primaryKey().defaultRandom(), id: uuid("id").primaryKey().defaultRandom(),
createdAt: timestamp("created_at", { withTimezone: true }) created_at: timestamp("created_at", { withTimezone: true })
.notNull() .notNull()
.defaultNow(), .defaultNow(),
@@ -11,7 +11,7 @@ export const authUsers = pgTable("auth_users", {
passwordHash: text("password_hash").notNull(), passwordHash: text("password_hash").notNull(),
multiTenant: boolean("multi_tenant").notNull().default(true), multiTenant: boolean("multi_tenant").notNull().default(true),
mustChangePassword: boolean("must_change_password").notNull().default(false), must_change_password: boolean("must_change_password").notNull().default(false),
updatedAt: timestamp("updated_at", { withTimezone: true }), updatedAt: timestamp("updated_at", { withTimezone: true }),

View File

@@ -19,19 +19,19 @@ import { createddocuments } from "./createddocuments"
import { bankstatements } from "./bankstatements" import { bankstatements } from "./bankstatements"
import { accounts } from "./accounts" // Falls noch nicht erstellt → bitte melden! import { accounts } from "./accounts" // Falls noch nicht erstellt → bitte melden!
export const statementAllocations = pgTable("statementallocations", { export const statementallocations = pgTable("statementallocations", {
id: uuid("id").primaryKey().defaultRandom(), id: uuid("id").primaryKey().defaultRandom(),
// foreign keys // foreign keys
bsId: integer("bs_id") bs_id: integer("bs_id")
.notNull() .notNull()
.references(() => bankstatements.id), .references(() => bankstatements.id),
cdId: integer("cd_id").references(() => createddocuments.id), cd_id: integer("cd_id").references(() => createddocuments.id),
amount: doublePrecision("amount").notNull().default(0), amount: doublePrecision("amount").notNull().default(0),
iiId: bigint("ii_id", { mode: "number" }).references( ii_id: bigint("ii_id", { mode: "number" }).references(
() => incominginvoices.id () => incominginvoices.id
), ),
@@ -64,6 +64,6 @@ export const statementAllocations = pgTable("statementallocations", {
archived: boolean("archived").notNull().default(false), archived: boolean("archived").notNull().default(false),
}) })
export type StatementAllocation = typeof statementAllocations.$inferSelect export type StatementAllocation = typeof statementallocations.$inferSelect
export type NewStatementAllocation = export type NewStatementAllocation =
typeof statementAllocations.$inferInsert typeof statementallocations.$inferInsert