← back to Grassclothwallpaper
supabase-setup.sql
96 lines
-- ============================================
-- SQL COMMANDS FOR SUPABASE SQL EDITOR
-- ============================================
-- Go to: SQL Editor > New Query
-- Copy and paste all of this, then click "Run"
-- Drop existing tables if they exist (optional - for clean setup)
DROP TABLE IF EXISTS sample_requests CASCADE;
DROP TABLE IF EXISTS grasscloth_products CASCADE;
-- Create Grasscloth Products Table
CREATE TABLE grasscloth_products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
sku VARCHAR(100) UNIQUE,
color VARCHAR(100),
brand VARCHAR(100) DEFAULT 'Phillipe Romano',
category VARCHAR(100) DEFAULT 'Grasscloth',
url TEXT,
image_url TEXT,
description TEXT,
width VARCHAR(50) DEFAULT '36"',
price_per_yard DECIMAL(10,2),
in_stock BOOLEAN DEFAULT true,
featured BOOLEAN DEFAULT false,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Create indexes for better performance
CREATE INDEX idx_grasscloth_name ON grasscloth_products(name);
CREATE INDEX idx_grasscloth_sku ON grasscloth_products(sku);
CREATE INDEX idx_grasscloth_featured ON grasscloth_products(featured);
-- Create Sample Requests Table
CREATE TABLE sample_requests (
id SERIAL PRIMARY KEY,
product_name VARCHAR(255),
product_sku VARCHAR(100),
customer_name VARCHAR(255) NOT NULL,
customer_email VARCHAR(255) NOT NULL,
customer_phone VARCHAR(50),
company VARCHAR(255),
address TEXT,
city VARCHAR(100),
state VARCHAR(50),
zip VARCHAR(20),
country VARCHAR(100) DEFAULT 'USA',
message TEXT,
status VARCHAR(50) DEFAULT 'pending',
created_at TIMESTAMP DEFAULT NOW()
);
-- Create indexes for sample requests
CREATE INDEX idx_requests_email ON sample_requests(customer_email);
CREATE INDEX idx_requests_status ON sample_requests(status);
-- Enable Row Level Security (RLS)
ALTER TABLE grasscloth_products ENABLE ROW LEVEL SECURITY;
ALTER TABLE sample_requests ENABLE ROW LEVEL SECURITY;
-- Create RLS Policies
-- Everyone can view products
CREATE POLICY "Public can view products"
ON grasscloth_products FOR SELECT
USING (true);
-- Everyone can create sample requests
CREATE POLICY "Public can create sample requests"
ON sample_requests FOR INSERT
WITH CHECK (true);
-- Only authenticated users can view sample requests
CREATE POLICY "Authenticated can view requests"
ON sample_requests FOR SELECT
USING (auth.role() = 'authenticated');
-- Insert initial Phillipe Romano products
INSERT INTO grasscloth_products (name, sku, color, description, price_per_yard, featured) VALUES
('PR-101 Natural Sisal', 'PR-101', 'Natural Sisal', 'Natural sisal grasscloth with subtle texture and organic beauty', 125.00, true),
('PR-102 Sage Green', 'PR-102', 'Sage Green', 'Soft sage green grasscloth with natural fiber variations', 125.00, true),
('PR-103 Charcoal', 'PR-103', 'Charcoal', 'Sophisticated charcoal grasscloth with rich depth', 135.00, false),
('PR-104 Ivory', 'PR-104', 'Ivory', 'Elegant ivory grasscloth with delicate weave pattern', 125.00, false),
('PR-105 Navy Blue', 'PR-105', 'Navy Blue', 'Deep navy blue grasscloth with luxurious texture', 135.00, true),
('PR-106 Taupe', 'PR-106', 'Taupe', 'Warm taupe grasscloth with natural variations', 125.00, false),
('PR-107 Pearl', 'PR-107', 'Pearl', 'Lustrous pearl grasscloth with subtle shimmer', 145.00, false),
('PR-108 Terracotta', 'PR-108', 'Terracotta', 'Warm terracotta grasscloth with earthy appeal', 125.00, false),
('PR-109 Silver', 'PR-109', 'Silver', 'Contemporary silver grasscloth with metallic undertones', 145.00, true),
('PR-110 Moss Green', 'PR-110', 'Moss Green', 'Rich moss green grasscloth inspired by nature', 125.00, false);
-- Verify the setup
SELECT COUNT(*) as product_count FROM grasscloth_products;
SELECT * FROM grasscloth_products ORDER BY name LIMIT 5;