28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
import { integer, pgTable, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
import { orders } from './orders.js';
|
|
export const orderImeis = pgTable('order_imeis', {
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
orderId: uuid('order_id')
|
|
.notNull()
|
|
.references(() => orders.id, { onDelete: 'cascade' }),
|
|
imei: text('imei').notNull(),
|
|
fotaModel: text('fota_model'),
|
|
fotaSerial: text('fota_serial'),
|
|
fotaCurrentFirmware: text('fota_current_firmware'),
|
|
fotaActivityStatus: integer('fota_activity_status'),
|
|
fotaSeenAt: text('fota_seen_at'),
|
|
fotaCompanyId: integer('fota_company_id'),
|
|
fotaCompanyName: text('fota_company_name'),
|
|
fotaGroupId: integer('fota_group_id'),
|
|
fotaGroupName: text('fota_group_name'),
|
|
fotaLookupError: text('fota_lookup_error'),
|
|
fotaLastLookupAt: timestamp('fota_last_lookup_at', { withTimezone: true }),
|
|
fotaMovedAt: timestamp('fota_moved_at', { withTimezone: true }),
|
|
fotaMoveError: text('fota_move_error'),
|
|
createdAt: timestamp('created_at', { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow()
|
|
}, (t) => ({
|
|
orderImeiUniqueIdx: uniqueIndex('order_imeis_order_id_imei_unique').on(t.orderId, t.imei)
|
|
}));
|