Back

Modifying Attribute size

  • 2
  • Databases
  • Cloud
Marco Napoli
12 Apr, 2024, 21:57

I am currently creating a database with the collections and appropriate attributes. No data has been entered yet, still in the development stage.

I need to change the attribute size but it does not allow it. Is there a way to change? Otherwise, you need to delete the attribute and re-enter. But what happens once it's in production and an attribute size needs to increase?

I am coming from environments where the size of a field is not defined. For example, in a notes field, you set it up for 1000 characters but you need it to be as small as 0 or as big as 100000, automatically size variable length.

If I create fields bigger than what I need, is the storage size increased, or only use the characters entered?

Thank you for any suggestions, I appreciate it.

TL;DR
Developers inquiring about changing attribute sizes in Appwrite databases. Appwrite currently doesn't allow directly changing attribute sizes. Modifying columns on large tables might cause the database to lock up. Solution suggested: perform alterations in steps to avoid downtime. For future migrations, consider scheduling alterations during low-traffic hours. Storage size in Appwrite depends on the attribute's defined size, not just the entered characters.
Steven
13 Apr, 2024, 14:43

Changing a size can cause your database to lock up while the operation is done. The proper way to handle this in production is to do it in multiple steps. You can search online for zero downtime schema migrations

Marco Napoli
13 Apr, 2024, 18:05

I am used to using MS SQL Server where you can modify columns (attributes) in their Management Studio and it’s done. Scheduling database alterations were done at night time since the users are day only.

I believe you are speaking about duplicating the database, altering the scheme, copying the database, and so on…

  1. I was looking at Appwrite documentation at https://appwrite.io/docs/references/cloud/server-dart/databases#updateStringAttribute and I do not see an option to change the size of the attribute.
  2. If I create an attribute bigger than what I need, is the storage size increased, or only use the characters entered? For example, for a Text attribute with size 10,000 and the user only entered 10 characters, what is the size that is used on disk, 10,000 or 10 characters?

I am creating new apps and hopefully converting my apps from other platforms to Appwrite and I am trying to figure these things out.

Thank you for your help.

Steven
14 Apr, 2024, 05:50

Modifying columns on big tables can lock up the database.

  1. Yes, because it's not available.
  2. The underlying column type depends on the size you select for the string attribute. See https://github.com/utopia-php/database/blob/b6880e560242ef5629a4eeff334192bc342070de/src/Database/Adapter/MariaDB.php#L2103
Marco Napoli
14 Apr, 2024, 06:14

I understand what you are saying.

Since this is not accomplishable in the database dashboard, is there any documentation or FAQ on the Appwrite site handling changing an attribute size or how to accomplish changes by code?

Thank you for your help.

Steven
14 Apr, 2024, 16:04

Not at the moment, but you'd use the various server methods: https://appwrite.io/docs/references/cloud/server-rest/databases

Marco Napoli
14 Apr, 2024, 16:48

I think this is the part that I do not understand how the increase the size of the string attribute since the size parameter is missing:

https://appwrite.io/docs/references/cloud/server-rest/databases#updateStringAttribute

Thanks.

Steven
7 Jun, 2024, 14:46

Please create a separate #🚑│support post instead of posting in someone else's old thread

Sonicviz
13 Jun, 2024, 19:52

I did @ https://discord.com/channels/564160730845151244/1249577664138973194 but no response so far. Just want some clarifications

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