Schema migration

Change the structure of a table in Baseten Postgres.

A schema migration is when you update the structure of a Baseten Postgres table. The following actions are schema migrations:

  • Adding one or more columns

  • Deleting one or more columns

  • Renaming one or more columns

You cannot change the type of an existing column, even if the table is empty or the column is entirely null values.

Schema migrations cannot be undone; if you delete a column the data in that column is gone. You can always perform another migration to add back a column with the same name and type, but the data will stay gone.

Consider your entire application before modifying a table schema. If you're modifying a database that is actively being used:

  • If you're adding a column, add it to the database before referencing it in your queries.

  • If you're deleting a column, remove all references in your queries before deleting it.

  • If you're renaming a column, consider a multi-step process where you add a column with the new name, copy the data to the new column, change all references to the new column, and delete the old column.

To add a column, click the "Add column" button and give your new column a name and type. Added columns are nullable and any existing rows will have null set as the value for the new column.

To delete a column, click on the "X" next to the column and "Yes, remove it" in the confirmation modal.

Last updated