🍱 Database Tables

Add a database table for usernames

Which Postgres constraint is used to match against a regular expression?


Command to create a migration file from your current local Supabase state:

npx supabase db diff --use-migra --file=<name of the migration>

SQL to create our user profile table:

create table user_profiles (
  user_id uuid primary key references auth.users (id) not null,
  username text unique not null
  CONSTRAINT proper_username CHECK (username ~* '^[a-zA-Z0-9_]+$')
  CONSTRAINT username_length CHECK (char_length(username) > 3 and char_length(username) < 15)

Questions? Let's chat

Open Discord