If I use Glitch to make an app that has a database, and store the data locally in the container’s filesystem, is there a good way to make changes with minimal downtime?
I’ve seen people suggesting remixing the project and then swapping the project names once you’ve finished making changes, but then you lose the data that was changed while you were editing (which might take days).
Any strategies people are using?
Download the project, then push to the glitch git repo?
Have you gotten this to work before? I tried it just now, and I get this git error when I try to push from my computer to Glitch:
Never gotten that before, try not pushing every everything except code files (forgot to mention that)
maybe force push too
EDIT: also include the .data folder (in the push) which has all of your db
I think I found a working solution!
Clone the project locally with its git URL, and then create a new branch locally. You can commit and push this branch safely to the Glitch project.
When you’re ready, run git merge new_branch
and refresh
to show the new changes. I believe this preserves database files that are added to .gitignore
(I don’t want to include the database in git since that overwrites changes, the database should only exist on Glitch).
1 Like
Hi, this is a tricky question, because different applications will have different amount of care that is appropriate for the data or how much downtime is too much.
One possibility is to remix your project (in my case, ~cooked-fuchsia-hydrant), and then develop your new features in the remix (in my case ~four-mercurial-dart), and then in the console of the original,
- add the remix as a remote
- pull from the remix
- (optionally)
refresh
to see the changed code in the editor.
app@cooked-fuchsia-hydrant:~ 19:34
$ git remote add four-mercurial-dart https://0a480b1a-e7e6-4d5e-bd40-870bb84e6485@api.glitch.com/git/four-mercurial-dart
app@cooked-fuchsia-hydrant:~ 19:35
$ git pull four-mercurial-dart master
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From https://api.glitch.com/git/four-mercurial-dart
* branch master -> FETCH_HEAD
b7c1459..566d506 master -> four-mercurial-dart/master
Updating b7c1459..566d506
Fast-forward
views/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
app@cooked-fuchsia-hydrant:~ 19:35
$ refresh
This works well if the database is a Sqlite database stored in the .data directory and is therefore gitignored (you generally don’t want to keep binary data in Git, and on Glitch it can cause your disk space to gradually get used up).
If you need a copy of the production database in order to develop your new features, you might want to add a route to your application for downloading the .db file from the terminal in the remix.
Hope this helps,
Johnicholas
1 Like