27 lines
No EOL
1.1 KiB
SQL
27 lines
No EOL
1.1 KiB
SQL
-- Create items table (compatible with both PostgreSQL and SQLite)
|
|
CREATE TABLE IF NOT EXISTS items (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
label_id TEXT UNIQUE NOT NULL,
|
|
model_number TEXT,
|
|
remarks TEXT,
|
|
purchase_year INTEGER,
|
|
purchase_amount REAL,
|
|
durability_years INTEGER,
|
|
is_depreciation_target BOOLEAN DEFAULT FALSE,
|
|
connection_names TEXT, -- JSON array for both DBs
|
|
cable_color_pattern TEXT, -- JSON array for both DBs
|
|
storage_locations TEXT, -- JSON array for both DBs
|
|
is_on_loan BOOLEAN DEFAULT FALSE,
|
|
qr_code_type TEXT CHECK (qr_code_type IN ('qr', 'barcode', 'none')),
|
|
is_disposed BOOLEAN DEFAULT FALSE,
|
|
image_url TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Create indexes
|
|
CREATE INDEX IF NOT EXISTS idx_items_label_id ON items(label_id);
|
|
CREATE INDEX IF NOT EXISTS idx_items_name ON items(name);
|
|
CREATE INDEX IF NOT EXISTS idx_items_is_on_loan ON items(is_on_loan);
|
|
CREATE INDEX IF NOT EXISTS idx_items_is_disposed ON items(is_disposed); |