widgettdc-api / database /migrations /002-create-widgets-table.sql
Kraft102's picture
fix: sql.js Docker/Alpine compatibility layer for PatternMemory and FailureMemory
5a81b95
-- Migration: Create widgets table
CREATE TABLE IF NOT EXISTS widgets (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100) NOT NULL,
description TEXT,
version VARCHAR(20) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
stock_quantity INTEGER DEFAULT 0,
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_widgets_name ON widgets(name);
CREATE INDEX idx_widgets_owner ON widgets(owner_id);
CREATE INDEX idx_widgets_version ON widgets(version);