Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pglite migrations created against a supabase database are invalid #1237

Open
AntonOfTheWoods opened this issue May 8, 2024 · 1 comment
Open

Comments

@AntonOfTheWoods
Copy link
Contributor

AntonOfTheWoods commented May 8, 2024

Upgrading the checkout example to 0.11.0 for the image and 0.11.1 for the client allows one to successfully run with wa-sqlite. However, while a pg-migration.ts is generated, it is not able to be used with the current pglite integration.

...
      "CREATE TABLE items (\n    id uuid NOT NULL,\n    slug text NOT NULL,\n    name text NOT NULL,\n    price integer NOT NULL,\n    description text NOT NULL,\n    CONSTRAINT items_pkey PRIMARY KEY (id)\n);\n\n\nGRANT DELETE ON items TO anon;\nGRANT INSERT ON items TO anon;\nGRANT REFERENCES ON items TO anon;\nGRANT SELECT ON items TO anon;\nGRANT TRIGGER ON items TO anon;\nGRANT TRUNCATE ON items TO anon;\nGRANT UPDATE ON items TO anon;\nGRANT DELETE ON items TO authenticated;\nGRANT INSERT ON items TO authenticated;\nGRANT REFERENCES ON items TO authenticated;\nGRANT SELECT ON items TO authenticated;\nGRANT TRIGGER ON items TO authenticated;\nGRANT TRUNCATE ON items TO authenticated;\nGRANT UPDATE ON items TO authenticated;\nGRANT DELETE ON items TO postgres;\nGRANT INSERT ON items TO postgres;\nGRANT REFERENCES ON items TO postgres;\nGRANT SELECT ON items TO postgres;\nGRANT TRIGGER ON items TO postgres;\nGRANT TRUNCATE ON items TO postgres;\nGRANT UPDATE ON items TO postgres;\nGRANT DELETE ON items TO service_role;\nGRANT INSERT ON items TO service_role;\nGRANT REFERENCES ON items TO service_role;\nGRANT SELECT ON items TO service_role;\nGRANT TRIGGER ON items TO service_role;\nGRANT TRUNCATE ON items TO service_role;\nGRANT UPDATE ON items TO service_role;\n",
      "CREATE TABLE orders (\n    id uuid NOT NULL,\n    electric_user_id uuid NOT NULL,\n    recipient_name text NOT NULL,\n    delivery_address text NOT NULL,\n    delivery_postcode text NOT NULL,\n    delivery_country text NOT NULL,\n    delivery_price integer NOT NULL,\n    status text NOT NULL,\n    created_at timestamp without time zone NOT NULL,\n    CONSTRAINT orders_pkey PRIMARY KEY (id)\n);\n\n\nGRANT DELETE ON orders TO anon;\nGRANT INSERT ON orders TO anon;\nGRANT REFERENCES ON orders TO anon;\nGRANT SELECT ON orders TO anon;\nGRANT TRIGGER ON orders TO anon;\nGRANT TRUNCATE ON orders TO anon;\nGRANT UPDATE ON orders TO anon;\nGRANT DELETE ON orders TO authenticated;\nGRANT INSERT ON orders TO authenticated;\nGRANT REFERENCES ON orders TO authenticated;\nGRANT SELECT ON orders TO authenticated;\nGRANT TRIGGER ON orders TO authenticated;\nGRANT TRUNCATE ON orders TO authenticated;\nGRANT UPDATE ON orders TO authenticated;\nGRANT DELETE ON orders TO postgres;\nGRANT INSERT ON orders TO postgres;\nGRANT REFERENCES ON orders TO postgres;\nGRANT SELECT ON orders TO postgres;\nGRANT TRIGGER ON orders TO postgres;\nGRANT TRUNCATE ON orders TO postgres;\nGRANT UPDATE ON orders TO postgres;\nGRANT DELETE ON orders TO service_role;\nGRANT INSERT ON orders TO service_role;\nGRANT REFERENCES ON orders TO service_role;\nGRANT SELECT ON orders TO service_role;\nGRANT TRIGGER ON orders TO service_role;\nGRANT TRUNCATE ON orders TO service_role;\nGRANT UPDATE ON orders TO service_role;\n",
...

When executing we get normal logs:

applying migration: 0
...
applying migration: 1

This then errors with:

error: cannot insert multiple commands into a prepared statement...

If the (superfluous?) GRANTs are removed there are still issues remaining with the migrations created, and I will create separate issues for those.

Copy link

linear bot commented May 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant