USync settings with LocalDB for development
# help-with-umbraco
p
Hey everyone, with what type of sync mechanism between Local DB and staging DB do you work? How do you keep your Development in Sync with the staging environment?
j
This depends a little on the the client I'm working with. I tend not to keep DBs "in sync". It's very unusual that what I'm working on actually needs up-to-date content so I usually just use uSync to manage "settings "changes (schema changes, i.e. to doctypes etc.) automatically with "import at startup" and "export on save" set to true. Every now and then I clone the database from prod or staging to local (sometimes manually, sometimes automated). I never push content from development into staging/prod. This way features are never content-dependant and have fallbacks for when content isn't there. Also entering content becomes part of the editor's learning process for using the new feature. Bigger clients that use staging properly may have uSync complete, in that case I'll use that over a manual db sync but that's actually pretty rare (not least because even our biggest client that's using uSync complete isn't actually allowed to grant us access to the data on prod).
p
Thanks alot @Jason for your detailed answer! What is your automation for cloning databases and what type of local db are you using for development?
j
Good question, my scripts are a mess. Some use the az cli (az sql db) for export (many of our clients use Azure), others just use sqlpackage.exe. process is generally: 1. export bacpac from stage/prod 2. import to LocalDb using sqlpackage.exe. (I'm on windows). I use LocalDB (https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver16) for most things. It's a full SQL implementation but with auto stop/start. It does have a 10GB limit on the DB size though, so for bigger clients I use the official SQL Server docker image (so I can stop/start as needed, run multiple versions, and don't have to pollute my machine with all the MSSQL cruft).
m
On Windows with localDB, I use Azure Data Studio + SQL Server Dacpac extension for import/export of backpac rather than sqlpackage.exe
j
Yeah, SMSS, Data Studio and Visual Studio all have GUIs for SqlPackage. If you're feeling super nerdy you can also use DacFX (the underlying libs for SqlPackage) in C# https://github.com/microsoft/DacFx
7 Views