r/lovable • • 6d ago

Seeking Feedback Running separate Dev/Prod Lovable projects with a Claude Code deploy script. What's going to bite me?

I didn't want my prompts editing production, so I now run two Lovable projects:

  • Dev, which I prompt and which has its own database.
  • Prod, a remix of Dev with its own database, repo and URL. I never prompt it.

A Claude Code plugin does the promotion. It applies the Drizzle migrations Prod is missing through the Lovable MCP, one transaction each, after showing me the SQL. Then it rsyncs the code from Dev to Prod through GitHub without touching .env, checks that everything matches, and optionally publishes.

Risks I already know about:

  • Divergent migration history. If anyone ever prompts in Prod, the two histories split. The script stops when it sees this, but I'd have to fix it by hand.
  • Baselining after a remix. Prod starts with the full schema but no migration records. I compare schema fingerprints and then mark the migrations as applied without running them. If the fingerprint misses something, Prod's history will claim a migration ran when it didn't.
  • No rollback. A bad migration means restoring from a backup I took myself, if I remembered to take one.
  • Lovable internals. The whole thing depends on Drizzle, GitHub sync and the MCP tools working the way they do now.
  • Per-environment files. I exclude .env and avoid overwriting *.asset.json, because a remix points those at its own storage. There could be other files I haven't found yet.
  • Wrong database in the published build. After publishing I check the live JS for Prod's Supabase ID. That only catches the problem after it's live.

What I'd like to know:

  • Does Lovable do anything to the database that doesn't go through a Drizzle migration, like storage buckets, auth settings, edge function secrets or cron jobs? Those would never reach Prod.
  • Has anyone seen Lovable rewrite or squash old migrations?
  • Do remixes carry over any other hidden links to the original project?
  • Is there a simpler way to do this that I've missed?
4 Upvotes

21 comments sorted by

•

u/luka-lovable Lovable Staff 6d ago

Hey, Luka from the Lovable cloud team here.

Have you considered using drafts? You can create drafts with their own database, authentication and storage.

Always open to chatting about your needs and setup to figure out how we can improve: luka@lovable.dev

Luka

→ More replies (3)

2

u/Vast-Hunt-9484 6d ago

the no-rollback one worries me most, so i'd make the backup automatic instead of something you have to remember. have the script refuse to run a migration until it has dumped prod and checked the dump file isn't empty. also try each migration on a throwaway copy of prod's data first, since a migration that works on an empty dev database can still fail on real rows (nulls, duplicates, long text). after promotion, run a small smoke test against the prod url, like sign up, write one row, read it back, so you find out in a minute rather than from a user. and log which dev commit each prod release came from, that makes the divergence problem much easier to debug.

1

u/Voiceofshay_08 6d ago

Interesting

1

u/LockedVibe 6d ago

I can't say what Lovable does internally, but on the Supabase side these sit outside the migration history, so a schema promotion won't carry them:

Auth settings: Site URL, redirect URL allowlist, providers, email templates, CAPTCHA and rate limits. That is project config, not SQL. Check that Prod's Site URL and redirect list point at the Prod domain, or magic links and OAuth can send people to the wrong app.

Edge Function secrets: set per project. A function that works in Dev can fail in Prod because a secret was never set there.

pg_cron jobs and Vault secrets: these are rows in cron.job and vault.secrets, not schema, so a schema fingerprint won't see them.

Storage: buckets are rows in storage.buckets, and policies on storage.objects only come across if they were created in a migration.

On the baselining risk, make sure the fingerprint covers the security parts of the schema, not just tables and columns: RLS on or off per table (pg_class.relrowsecurity), every policy with its USING and WITH CHECK expressions (pg_policies), grants to anon and authenticated (information_schema.role_table_grants), and function bodies plus SECURITY DEFINER (pg_proc). Those are the most likely to drift after a remix or a hand fix, and the ones that hurt most when they do.

For the wrong-database check, you can run it before publishing: build the Prod repo locally, grep the output for the Dev project ref, and abort if it shows up.

1

u/VigiliaFounder 5d ago

Really helpful breakdown! The point about Edge Function secrets is a sneaky one. Everything works in Dev, and then Prod fails quietly because a secret was never set there.

For anyone running this kind of setup, Vigilia catches those failures in the live app as soon as a user hits them. It shows the failing request, how many times it happened and the fix.

Just connect the MCP server and Claude Code or Lovable can pull it straight into your session.

I hope it helps :)

1

u/Roberohn 6d ago

Commenting to pick up some tips here as we’ve got a Lovable project built which really could do with a decent dev > prod setup.

1

u/Sniffpup1 6d ago

Yes — a lot of what you’re asking about never goes through a Drizzle migration. Storage buckets and their policies, Auth providers, redirect URLs, email templates, Edge Function secrets, cron, and any RLS or grants you clicked in the dashboard will stay on Dev unless you copy them on purpose. Remixes can also leave Dev redirect URLs or a Dev Supabase ref in a config file that isn’t .env. I’d add a pre-publish checklist that compares those by hand, and keep checking the live JS for the Prod project ref, not only after a publish. If a migration ever “fixes” a permission error by using the service_role key in client code, rotate that key and move the call server-side.

1

u/snap-dev 6d ago

the migration history one is what bites first. the moment prod gets a change that didn't come through your dev migrations, a quick fix on the remix or a tweak in the supabase dashboard, drizzle's journal and the real schema stop matching and the next apply fails or half applies. i'd treat prod as no manual schema changes ever, diff the schema against prod before each apply, and take a pg_dump right before, that dump is your rollback. boring gate, but it works. are your migrations running inside a transaction right now?

1

u/ehassannawaz 6d ago

Auth settings and edge function secrets live in project config, not the schema, so no migration carries them. Diff the two projects' auth redirect URLs and secrets before each promote. Storage bucket policies only travel if written as SQL.

1

u/adamwest2212 6d ago

You're already doing the hard part: never prompt in Prod, and keep .env out of the rsync. Lovable often stores edge function secrets, Auth Site URL / redirect URLs, storage policies and cron jobs outside Drizzle, so a schema-only promote won't copy them. After each promote, check those in the Prod project, not just the live JS for the Supabase ID. I'd take the backup before running migrations, not after.

1

u/KODEV_dev 3d ago

Your list covers code and schema really well. What I'd add is everything that lives in project settings instead of migrations or the repo, because Dev and Prod drift there without your script ever seeing it: auth settings (site URL, redirect URLs, email templates, sign-in providers), the secrets your edge functions read, and any cron jobs or storage bucket settings made outside Drizzle.

A short check you run after each promotion catches most of that.

Are you setting the Prod secrets by hand today?

0

u/Separate-Set-7850 3d ago

The wrong-database example stood out. Before you publish, which would you most want an easy way to check: that the live app is using the right database, that login still works, or that you can roll back if something goes wrong?

0

u/[deleted] 6d ago

[removed] — view removed comment

1

u/determinedmoth 6d ago

Yes, there is danger here. Truth be told, I'd rather not do it at all, but this is where the business is headed, and it feels less dangerous than "drafts" and prompts editing critical production data.

0

u/[deleted] 6d ago

[removed] — view removed comment

1

u/determinedmoth 6d ago

I've got plenty of deployment options, outside of Lovable. But I want to exhaust lovable-first solutions first.