This commit is contained in:
hibna
2026-02-21 13:02:41 +03:00
commit 2215003a4d
59 changed files with 6100 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import {
pgTable,
uuid,
varchar,
integer,
bigint,
text,
boolean,
timestamp,
} from 'drizzle-orm/pg-core';
import { organizations } from './organizations';
import { servers } from './servers';
export const nodes = pgTable('nodes', {
id: uuid('id').defaultRandom().primaryKey(),
organizationId: uuid('organization_id')
.notNull()
.references(() => organizations.id, { onDelete: 'cascade' }),
name: varchar('name', { length: 255 }).notNull(),
fqdn: varchar('fqdn', { length: 255 }).notNull(),
daemonPort: integer('daemon_port').default(8443).notNull(),
grpcPort: integer('grpc_port').default(50051).notNull(),
location: varchar('location', { length: 255 }),
memoryTotal: bigint('memory_total', { mode: 'number' }).notNull(),
diskTotal: bigint('disk_total', { mode: 'number' }).notNull(),
memoryOveralloc: integer('memory_overalloc').default(0).notNull(),
diskOveralloc: integer('disk_overalloc').default(0).notNull(),
daemonToken: text('daemon_token').notNull(),
tlsEnabled: boolean('tls_enabled').default(true).notNull(),
isOnline: boolean('is_online').default(false).notNull(),
lastHeartbeat: timestamp('last_heartbeat', { withTimezone: true }),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const allocations = pgTable('allocations', {
id: uuid('id').defaultRandom().primaryKey(),
nodeId: uuid('node_id')
.notNull()
.references(() => nodes.id, { onDelete: 'cascade' }),
serverId: uuid('server_id').references(() => servers.id, { onDelete: 'set null' }),
ip: varchar('ip', { length: 45 }).notNull(),
port: integer('port').notNull(),
isDefault: boolean('is_default').default(false).notNull(),
});