remake / remake-cli

Create interactive web apps with just HTML (Remake CLI)
https://remaketheweb.com/
MIT License
392 stars 27 forks source link

Support for migrations #31

Open panphora opened 3 years ago

panphora commented 3 years ago

Is your feature request related to a problem? Please describe. Currently there's no way to restructure the user data if your app is hosted on the Remake hosting service. This is necessary if the structure of your app's data changes.

For example, v1 of your app might only have a single to-do list. But, for v2, you want to have multiple to-do lists. You need a way to loop through all user data and moving their to-do list inside an array of to-do lists.

Describe the solution you'd like Since Remake probably won't support executing server-side code from users any time soon, an alternate solution would be to let devs modify user data locally and then re-upload it to their live app.

  1. Backup your app's data with remake backup and unzip it (currently available command)
  2. Shut down your remote app with remake shutdown-app (new command)
  3. Update the data in your local app by running a script on all the user data files (e.g. the script could be located in /app/data/migrate.js
  4. Upload your app data back to your production app with remake upload-user-data (new command)
  5. Restart your app with remake start-app (new command)

This could all be condensed into a single command remake migrate:

  1. Tell you what's going to happen — and confirm that you've double checked your /app/data/migrate.js file
  2. Run all the steps above in order
  3. Delete any temporary files, but leave the backup zip file so you can recover if you make a mistake

Describe alternatives you've considered An alternative would be to allow users to execute server code. This is a security risk right now, but if each user was limited to their own virtual server container, it could work.

panphora commented 3 years ago

Hey @charlietango, I don't know if this sounds interesting to you, but Remake could really use it. Currently, there's no way to undo a mistake in the structure of your data. A few users have requested migration support, as it's necessary for any serious use of Remake.

What do you think about the proposed solution?

ayshptk commented 3 years ago

This is a much-needed feature, please!!

Even if there isn't a perfect solution, there has to be some way at least to change the structure. The only thing Remake doesn't have to make it the best I guess 😳

charlietango commented 3 years ago

Hey @charlietango, I don't know if this sounds interesting to you, but Remake could really use it. Currently, there's no way to undo a mistake in the structure of your data. A few users have requested migration support, as it's necessary for any serious use of Remake.

What do you think about the proposed solution?

Hey @panphora let's talk this weekend about it. I will take some time to think about the feature and about the solution you suggested.

panphora commented 3 years ago

@charlietango We only really need one new command to support this: remake upload-user-data.

The shutdown-app and start-app commands aren't really necessary.

And, while we should add a feature that tells users their app is out of date and that they need to refresh to get the newest version, we can save this for a future feature build.

I think when the dev runs remake upload-user-data it should:

  1. Check to see if there's a ./app/data/database directory relative to the current directory and show an error if it's not there
  2. Inform the user that this command will upload the ./app/data/database directory from the app they're currently in (and name that app) and then show a bright red "WARNING: this will overwrite ALL the user data currently on the server"
  3. Ask the user if they want to proceed and only proceed if they answer "y" or "yes"
  4. Upload the ./app/data/database directory and replace their app's current database

I think that's all we need for now