Bird
Raised Fist0
Supabasecloud~5 mins

Creating migrations in Supabase - Quick Revision & Summary

Choose your learning style10 modes available
Recall & Review
beginner
What is a migration in the context of Supabase?
A migration is a file that records changes to the database schema, like creating or modifying tables, so you can apply these changes consistently across environments.
Click to reveal answer
beginner
How do you create a new migration using Supabase CLI?
You run the command supabase migration new <migration_name> to create a new migration file with the given name.
Click to reveal answer
intermediate
Why should migrations be version controlled?
Version control keeps track of all schema changes, helps teams collaborate, and allows you to roll back or replay changes safely.
Click to reveal answer
intermediate
What is the difference between 'up' and 'down' in a migration file?
'Up' defines the changes to apply (like creating tables), while 'down' defines how to undo those changes (like dropping tables).
Click to reveal answer
beginner
How do migrations help when working with multiple environments (development, staging, production)?
Migrations ensure that all environments have the same database structure by applying the same set of changes in order.
Click to reveal answer
Which command creates a new migration file in Supabase CLI?
Asupabase db create
Bsupabase migration new <migration_name>
Csupabase migration apply
Dsupabase start migration
What does the 'down' section in a migration file do?
ARuns tests on the migration
BApplies new changes to the database
CCreates a backup of the database
DRolls back or undoes changes
Why is it important to keep migrations in version control?
ATo track and manage schema changes safely
BTo speed up database queries
CTo share database passwords
DTo store user data
What is the main benefit of using migrations across multiple environments?
AAutomatically scales the database
BImproves network speed
CEnsures consistent database structure everywhere
DEncrypts data in transit
Which file type usually contains migration scripts in Supabase?
A.sql
B.html
C.json
D.js
Explain the purpose of migrations in Supabase and how they help manage database changes.
Think about how you keep track of changes to your database structure over time.
You got /4 concepts.
    Describe the steps to create and apply a migration using Supabase CLI.
    Consider the commands and actions needed from creating to applying a migration.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the main purpose of creating migrations in Supabase?
      easy
      A. To save and track changes made to the database structure
      B. To create user accounts automatically
      C. To deploy frontend code to the server
      D. To monitor server uptime and performance

      Solution

      1. Step 1: Understand what migrations do

        Migrations are files that record changes to the database schema over time.
      2. Step 2: Identify the purpose in Supabase context

        Supabase uses migrations to save and track database structure changes so they can be applied consistently.
      3. Final Answer:

        To save and track changes made to the database structure -> Option A
      4. Quick Check:

        Migrations = track database changes [OK]
      Hint: Migrations always track database structure changes [OK]
      Common Mistakes:
      • Confusing migrations with user management
      • Thinking migrations deploy frontend code
      • Assuming migrations monitor server health
      2. Which command creates a new migration file in Supabase?
      easy
      A. supabase migration up
      B. supabase db push
      C. supabase migration new
      D. supabase start migration

      Solution

      1. Step 1: Recall Supabase migration commands

        The command to create a new migration file is specifically designed to generate the file for changes.
      2. Step 2: Match command to action

        supabase migration new creates a new migration file, while others apply or push changes.
      3. Final Answer:

        supabase migration new -> Option C
      4. Quick Check:

        Create migration file = supabase migration new [OK]
      Hint: New migration files use 'migration new' command [OK]
      Common Mistakes:
      • Using 'db push' to create migration files
      • Confusing 'migration up' with creation
      • Typing incorrect commands like 'start migration'
      3. After creating a migration file, which command applies the changes to your remote database?
      medium
      A. supabase migration up
      B. supabase db push
      C. supabase migration new
      D. supabase db pull

      Solution

      1. Step 1: Understand commands for applying migrations

        supabase db push applies schema changes to the remote database by pushing local migrations.
      2. Step 2: Differentiate commands

        supabase migration up applies migrations locally, while supabase db push pushes changes remotely.
      3. Final Answer:

        supabase db push -> Option B
      4. Quick Check:

        Apply remotely = db push [OK]
      Hint: Use 'supabase db push' to apply migrations remotely [OK]
      Common Mistakes:
      • Using 'supabase migration up' to apply migrations remotely
      • Confusing 'migration new' as apply command
      • Thinking 'db pull' applies migrations
      4. You ran supabase migration up but got an error saying migrations are missing. What is the likely cause?
      medium
      A. You used the wrong command to apply locally
      B. You need to restart the Supabase server
      C. Your database connection is offline
      D. You forgot to create migration files before applying

      Solution

      1. Step 1: Analyze the error about missing migrations

        The error indicates no migration files exist to apply locally.
      2. Step 2: Identify the cause

        This usually happens if migration files were never created with supabase migration new.
      3. Final Answer:

        You forgot to create migration files before applying -> Option D
      4. Quick Check:

        Missing migrations = no files created [OK]
      Hint: Create migration files before applying locally [OK]
      Common Mistakes:
      • Assuming connection issues cause missing migrations
      • Restarting server without creating files
      • Confusing local and remote apply commands
      5. You want to update your remote Supabase database with new schema changes. Which sequence of commands should you run?
      hard
      A. supabase migration new -> supabase start -> supabase migration up
      B. supabase db push -> supabase migration new -> supabase migration up
      C. supabase migration up -> supabase migration new -> supabase db push
      D. supabase migration new -> supabase migration up -> supabase db push

      Solution

      1. Step 1: Create migration files first

        Use supabase migration new to save schema changes as migration files.
      2. Step 2: Apply changes locally

        Run supabase start to update your local database with these changes.
      3. Step 3: Apply migrations remotely

        Finally, run supabase migration up to update the remote database.
      4. Final Answer:

        supabase migration new -> supabase start -> supabase migration up -> Option A
      5. Quick Check:

        Create -> local start -> remote up [OK]
      Hint: Create migration, start locally, then up remotely [OK]
      Common Mistakes:
      • Applying migrations before creating files
      • Applying remotely before local test
      • Mixing order of commands
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard