Back

Changing an Attribute from URL to String in Appwrite

  • 0
  • Web
  • Cloud
JP
23 Mar, 2025, 15:19

I initially set up my Appwrite database to store user-inputted URLs as a URL type attribute. However, this has introduced some complications, and I now want to change the attribute type to String while validating it accordingly.

The challenge is that I already have several existing documents where the data is stored as a URL type. How can I safely convert the attribute to a String type without losing or corrupting the existing records? What would be the best approach to make this transition smoothly?

TL;DR
Developers want to switch a URL attribute to a String in Appwrite without losing existing data. To do this safely: 1. Create a new String attribute. 2. Update your app to write both URL and String attributes for new data. 3. Develop a script to migrate existing URL data to the new String attribute. 4. Update your app to use the new String attribute. 5. Ensure validation for URL format continues on new entries.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more