Add user_id FK column to charts, annotations, annotation_types, span_annotations, span_label_types
Adds nullable uuid user_id column referencing users.id to each of the 5 data tables. Column is nullable for now to allow the data migration script (task 2.5) to backfill existing rows before enforcing NOT NULL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9101cfb7af
commit
633a76876f
1 changed files with 5 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ export const users = pgTable('users', {
|
|||
|
||||
export const charts = pgTable('charts', {
|
||||
id: serial('id').primaryKey(),
|
||||
user_id: uuid('user_id').references(() => users.id), // nullable for now; will be NOT NULL after data migration (task 2.5)
|
||||
name: text('name').notNull().unique(),
|
||||
created_at: timestamp('created_at').notNull().defaultNow(),
|
||||
});
|
||||
|
|
@ -33,6 +34,7 @@ export const candles = pgTable('candles', {
|
|||
|
||||
export const annotationTypes = pgTable('annotation_types', {
|
||||
id: serial('id').primaryKey(),
|
||||
user_id: uuid('user_id').references(() => users.id), // nullable for now; will be NOT NULL after data migration (task 2.5)
|
||||
name: text('name').notNull().unique(), // internal name (e.g., 'break_up')
|
||||
display_name: text('display_name').notNull(), // display name (e.g., 'Break Up')
|
||||
color: text('color').notNull(), // hex color code
|
||||
|
|
@ -44,6 +46,7 @@ export const annotationTypes = pgTable('annotation_types', {
|
|||
|
||||
export const annotations = pgTable('annotations', {
|
||||
id: serial('id').primaryKey(),
|
||||
user_id: uuid('user_id').references(() => users.id), // nullable for now; will be NOT NULL after data migration (task 2.5)
|
||||
chart_id: integer('chart_id').notNull().references(() => charts.id),
|
||||
timestamp: timestamp('timestamp').notNull(),
|
||||
label_type: text('label_type').notNull(),
|
||||
|
|
@ -54,6 +57,7 @@ export const annotations = pgTable('annotations', {
|
|||
|
||||
export const spanLabelTypes = pgTable('span_label_types', {
|
||||
id: serial('id').primaryKey(),
|
||||
user_id: uuid('user_id').references(() => users.id), // nullable for now; will be NOT NULL after data migration (task 2.5)
|
||||
name: text('name').notNull().unique(), // internal name (e.g., 'bull_flag')
|
||||
display_name: text('display_name').notNull(), // UI label (e.g., 'Bull Flag')
|
||||
color: text('color').notNull(), // hex color for rectangle fill
|
||||
|
|
@ -65,6 +69,7 @@ export const spanLabelTypes = pgTable('span_label_types', {
|
|||
|
||||
export const spanAnnotations = pgTable('span_annotations', {
|
||||
id: serial('id').primaryKey(),
|
||||
user_id: uuid('user_id').references(() => users.id), // nullable for now; will be NOT NULL after data migration (task 2.5)
|
||||
chart_id: integer('chart_id').notNull().references(() => charts.id),
|
||||
start_time: timestamp('start_time').notNull(), // timestamp of first candle
|
||||
end_time: timestamp('end_time').notNull(), // timestamp of last candle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue