Free tier launching soon. Star our Github repo to keep up to date. 🙌
2019-11-08

How to add empty string as default value for text field in Hasura

elitasson
Johan Eliasson

Let's say we have a table posts and we want to add a new column tag which should be an empty string by default.

Hasura console
Hasura console

We can not add our tag text field with a default empty string using the Hasura console's "Add a new column". Instead we must add the column manually to the PostgreSQL database.

Click on SQL in the left menu in the Hasura console to insert the following SQL statement:

ALTER TABLE "posts" ADD COLUMN "tag" text NOT NULL DEFAULT '';
Adding column tag to table posts
Adding column tag to table posts

Click Run. Your new tag column with a default empty string is added to the posts table!

What's next?
Did you find this blog post interesting? Follow Nhost on Twitter.
Subscribe to the newsletter
Future of app development - stay up-to-date.
Try Nhost for Free Today
Focus on your app and your users!

Serverless backend for modern web and mobile apps

© Nhost
githubtwitterdiscordyoutubelinkedin