// schema.ts
import { createId } from '@paralleldrive/cuid2';
import { integer, pgTable, text, timestamp } from 'drizzle-orm/pg-core';
export const goals = pgTable('goals', {
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
title: text('title').notNull(),
desiredWeeklyFrequency: integer('desired_weekly_frequency').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});
export const completedGoals = pgTable('completed_goals', {
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
goalId: text('goal_id')
.references(() => goals.id, { onDelete: 'cascade' })
.notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});
// schema.ts
import { createId } from '@paralleldrive/cuid2';
import { integer, pgTable, text, timestamp } from 'drizzle-orm/pg-core';
export const goals = pgTable('goals', {
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
title: text('title').notNull(),
desiredWeeklyFrequency: integer('desired_weekly_frequency').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});
export const completedGoals = pgTable('completed_goals', {
id: text('id')
.primaryKey()
.$defaultFn(() => createId()),
goalId: text('goal_id')
.references(() => goals.id, { onDelete: 'cascade' })
.notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});