18 lines
736 B
SQL
18 lines
736 B
SQL
-- Migration 027: Customer Notes Table
|
|
-- Add table for storing internal notes about customers
|
|
-- Including subscription comments and other note types
|
|
|
|
CREATE TABLE IF NOT EXISTS customer_notes (
|
|
id SERIAL PRIMARY KEY,
|
|
customer_id INTEGER NOT NULL REFERENCES customers(id) ON DELETE CASCADE,
|
|
note_type VARCHAR(50) NOT NULL, -- 'subscription_comment', 'general', 'support', etc.
|
|
note TEXT NOT NULL,
|
|
created_by VARCHAR(100),
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Create index for efficient queries
|
|
CREATE INDEX IF NOT EXISTS idx_customer_notes_customer_id ON customer_notes(customer_id);
|
|
CREATE INDEX IF NOT EXISTS idx_customer_notes_type ON customer_notes(note_type);
|