Changing database structure with live users

I’m making a change to my database structure. Too much information was stored on the User, so I moved some of that into a separate table.

I’ve made the change on Dev and everything is working now. But if I publish it to the liver site, the website will break for users who already have data. The good news is that I don’t have many users yet and they don’t have much data yet.

How can I move the data for the users that exist? Is there any way to migrate the data? If not, will I be able to do it manually? How?

  1. Copy your User’s database from LIVE version into the development version.

  2. Create a workflow to organize your data in this new table. Doing this you will have an updated database using your new structure.

  3. Now, deploy a new version of your App (this will push also the new structure of your database into live version).

  4. And the last part… Copy your Users’s database from your DEVELOPMENT version into the live version (as well as the data from this other new table).

Just make sure to NOT delete your table columns before you perform this operation, because I assume that your new User’s database (the one you have in development) have less data than the database that you have in live version. So when you copy from live version into development version, you need to have all the columns in order to recieve the information. Delete the unwanted columns only after the whole process.

3 Likes

Hi there @rpetribu and thanks for this explanation.
Hope you don’t mind reopening the thread and asking one more detail about the steps you proposed.
Can you help me out clarifying the type of workflow to create to organize your data in this new database structure?
I’m having the exact same challenge as @brenton.strine , but my live app contains quite a lot of data already… So I really want to make sure I get this right before proceeding to any deployment :wink:
Thanks in advance!

Hi @a.grampa :wave:

Ok, so imagine you User database has tones of information about your users and you want to create a new database to store the address of these users in order to lower the size of your main database (Users). This new database called User-Address should have some fields like:

  • User (User type)
  • Address (Text type)
  • Number (Number type)
  • State (Text type)
  • City (Text type)
  • Zip Code (Text type)

So how can you migrate the information from your User database to this new User-Address database?

One way is creating a backend workflow to do it.

Create a backend workflow with one parameter called “api_user” (User type).

image

You only need one action in this workflow: Create a thing. A User-Address.

Now you have to set if up like:

User = api_user
Address = api_user’s address
Number = api_user’s address-number
State = api_user’s State
City = api_user’s City
Zip Code = api_user’s ZipCode

The last part is go to your database Users, select all your users and click the button “Bulk”. Than select the backend workflow you created, this will run the workflow with all your users as the parameter.

By doing this you will end up creating a new database with the addresses of all your users, which will be linked to them by the user field.

Make sense?

2 Likes