26 lines
1.2 KiB
SQL
26 lines
1.2 KiB
SQL
-- 1. First, forcefully drop the choked table. This is nearly instant as it skips row-by-row deletion.
|
|
DROP TABLE IF EXISTS public.aviation_history;
|
|
|
|
-- 2. Recreate the table exactly as it was, but fresh.
|
|
CREATE TABLE public.aviation_history (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
timestamp TIMESTAMPTZ NOT NULL,
|
|
icao24 TEXT NOT NULL,
|
|
callsign TEXT,
|
|
longitude DOUBLE PRECISION,
|
|
latitude DOUBLE PRECISION,
|
|
altitude DOUBLE PRECISION,
|
|
speed DOUBLE PRECISION,
|
|
heading DOUBLE PRECISION
|
|
);
|
|
|
|
-- 3. Immediately build the index we need on the empty table so queries are permanently fast.
|
|
CREATE INDEX idx_aviation_history_timestamp ON public.aviation_history (timestamp DESC);
|
|
|
|
-- 4. Re-enable Row Level Security (RLS) if you previously had policies.
|
|
-- (By default, tables in Supabase should have RLS enabled if accessed from client, but since we insert from server and read from server/client, you might just need the policy or leave it disabled if you only access via Service Role)
|
|
|
|
-- To allow anyone to read (if accessed directly from client):
|
|
-- ALTER TABLE public.aviation_history ENABLE ROW LEVEL SECURITY;
|
|
-- CREATE POLICY "Allow public read access" ON public.aviation_history FOR SELECT USING (true);
|