30 lines
562 B
PL/PgSQL
30 lines
562 B
PL/PgSQL
-- Create a table called "todos"
|
|
-- with a column to store tasks.
|
|
BEGIN;
|
|
DROP TABLE IF EXISTS "todos";
|
|
CREATE TABLE todos(
|
|
id serial PRIMARY KEY,
|
|
task text
|
|
);
|
|
|
|
-- Turn on security
|
|
ALTER TABLE "todos" ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Allow anonymous access
|
|
CREATE POLICY "Allow public access" ON todos
|
|
FOR SELECT TO anon
|
|
USING (TRUE);
|
|
|
|
-- Turn on security
|
|
ALTER TABLE "todos" ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Add some data
|
|
INSERT INTO todos(task)
|
|
VALUES
|
|
('Create tables'),
|
|
('Enable security'),
|
|
('Add data'),
|
|
('Fetch data from the API');
|
|
COMMIT;
|
|
|