All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { pgTable, text, timestamp, index, unique } from 'drizzle-orm/pg-core';
|
|
import { createId } from '@paralleldrive/cuid2';
|
|
|
|
export const POLICY_TYPES = [
|
|
'deviceConfiguration',
|
|
'compliancePolicy',
|
|
'windowsUpdateForBusiness',
|
|
'endpointSecurity',
|
|
'appConfiguration',
|
|
'enrollmentRestriction',
|
|
'conditionalAccess',
|
|
] as const;
|
|
|
|
export type PolicyType = (typeof POLICY_TYPES)[number];
|
|
|
|
export const policySettings = pgTable(
|
|
'policy_settings',
|
|
{
|
|
id: text('id')
|
|
.primaryKey()
|
|
.$defaultFn(() => createId()),
|
|
|
|
tenantId: text('tenant_id').notNull(),
|
|
|
|
policyName: text('policy_name').notNull(),
|
|
|
|
policyType: text('policy_type').notNull(),
|
|
|
|
settingName: text('setting_name').notNull(),
|
|
|
|
settingValue: text('setting_value').notNull(),
|
|
|
|
graphPolicyId: text('graph_policy_id').notNull(),
|
|
|
|
lastSyncedAt: timestamp('last_synced_at', { mode: 'date' })
|
|
.defaultNow()
|
|
.notNull(),
|
|
|
|
createdAt: timestamp('created_at', { mode: 'date' }).defaultNow().notNull(),
|
|
},
|
|
(table) => ({
|
|
tenantIdIdx: index('policy_settings_tenant_id_idx').on(table.tenantId),
|
|
settingNameIdx: index('policy_settings_setting_name_idx').on(
|
|
table.settingName
|
|
),
|
|
// Unique constraint for ON CONFLICT upsert
|
|
upsertUnique: unique('policy_settings_upsert_unique').on(
|
|
table.tenantId,
|
|
table.graphPolicyId,
|
|
table.settingName
|
|
),
|
|
})
|
|
);
|
|
|
|
export type PolicySetting = typeof policySettings.$inferSelect;
|
|
export type NewPolicySetting = typeof policySettings.$inferInsert;
|