Enter the admin password to continue.
Incorrect password.
One-time utility to import all rugs from cleaned-products.json into Supabase.
Found in: Supabase Dashboard → Settings → API → Project URL
Found in: Supabase Dashboard → Settings → API → Service Role (secret). Never use in client code.
This will run the SQL to create the rugs table (if it doesn't exist) and create the ar-models storage bucket.
It's safe to run multiple times. All statements use CREATE IF NOT EXISTS.
CREATE TABLE IF NOT EXISTS rugs (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
sku TEXT UNIQUE,
slug TEXT UNIQUE NOT NULL,
description TEXT,
price NUMERIC(10,2) DEFAULT 0,
images TEXT[] DEFAULT '{}',
size TEXT,
origin TEXT,
style TEXT,
material TEXT,
construction TEXT,
colors TEXT[] DEFAULT '{}',
condition TEXT DEFAULT 'New',
tags TEXT[] DEFAULT '{}',
visible BOOLEAN DEFAULT true,
consignment BOOLEAN DEFAULT false,
consigner TEXT,
ar_usdz_url TEXT,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_rugs_origin ON rugs(origin);
CREATE INDEX IF NOT EXISTS idx_rugs_visible ON rugs(visible);
CREATE INDEX IF NOT EXISTS idx_rugs_slug ON rugs(slug);
Loads /cleaned-products.json from this server and upserts all records into Supabase by SKU.
Existing records are updated; new ones are inserted.
Must be accessible from this browser. Relative path works if served locally.
After importing, set up RLS policies so only authenticated admins can write to the rugs table,
while the anon key can read visible rugs. Run this SQL in the Supabase SQL Editor:
-- Enable RLS
ALTER TABLE rugs ENABLE ROW LEVEL SECURITY;
-- Allow anon to read visible rugs (for public gallery/product pages)
CREATE POLICY "Public can read visible rugs"
ON rugs FOR SELECT
USING (visible = true);
-- Allow service role full access (used by import script)
-- (No policy needed; service role bypasses RLS by default)
-- Allow authenticated users full access (for inventory manager)
CREATE POLICY "Authenticated users can manage rugs"
ON rugs FOR ALL
TO authenticated
USING (true)
WITH CHECK (true);
-- ar-models bucket: public reads, authenticated writes
INSERT INTO storage.buckets (id, name, public)
VALUES ('ar-models', 'ar-models', true)
ON CONFLICT (id) DO NOTHING;
Run this in: Supabase Dashboard → SQL Editor → New Query → Paste → Run