mirror of
https://github.com/Dvorinka/Bookra.git
synced 2026-06-03 20:13:00 +00:00
21 lines
718 B
SQL
21 lines
718 B
SQL
-- +goose Up
|
|
-- Create customers table for customer management
|
|
CREATE TABLE IF NOT EXISTS customers (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
name text NOT NULL,
|
|
email text NOT NULL,
|
|
phone text,
|
|
status text NOT NULL DEFAULT 'active',
|
|
notes text,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_customers_tenant ON customers (tenant_id);
|
|
CREATE INDEX IF NOT EXISTS idx_customers_email ON customers (tenant_id, email);
|
|
CREATE INDEX IF NOT EXISTS idx_customers_status ON customers (tenant_id, status);
|
|
|
|
-- +goose Down
|
|
DROP TABLE IF EXISTS customers;
|