---
title: "Declarative Schemas for Simpler Database Management"
description: "Supabase CLI now supports declarative schemas: the desired final state of Postgres tables, views, functions, RLS policies, grants and types lives in versioned .sql files, and a schema diff tool such as migra generates the migration files."
url: "https://swe.quest/articles/declarative-schemas-for-simpler-database-management-ee2428d0ae8c51e8"
canonical: "https://supabase.com/blog/declarative-schemas"
source: "Supabase"
published: "2025-04-03"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 4
tags: ["schema-migrations","postgres","developer-tools"]
---

# Declarative Schemas for Simpler Database Management

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2025-04-03, 4 min read, Announcement. Original: [https://supabase.com/blog/declarative-schemas](https://supabase.com/blog/declarative-schemas)

## Summary

Supabase CLI now supports declarative schemas: the desired final state of Postgres tables, views, functions, RLS policies, grants and types lives in versioned .sql files, and a schema diff tool such as migra generates the migration files. Supabase used this internally for two years on its complex projects table, which sits in a private schema behind a public view with RLS-based ABAC and INSTEAD OF triggers. Previously, adding one column meant hand-copying view and trigger definitions into a migration of several hundred lines that conflicted often. Now it is a one-line diff, and generated migrations still get manual review. The team says this cut schema changes from hours to minutes and made rebasing much easier.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- database migrations ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- row level security ([easy posts on Security](https://swe.quest/tags/security.md?difficulty=easy))

## Keywords

Supabase, Supabase CLI, migra, PostgREST, pgTAP, row level security

## Related posts

- [Declarative Schemas 2.0 with pg-delta](https://swe.quest/articles/declarative-schemas-2-0-with-pg-delta-0896bf8f6c8dbe4f.md): Supabase · 2026-10-13 · Medium · 11 min read · Schema migrations, PostgreSQL, Developer tools, Open source
  Supabase replaced migra with pg-delta, its own open-source Postgres diff engine, as the generator behind declarative schema migrations in the Supabase CLI. pg-delta loads schema files and migration history into two shadow databases, diffs them by reading the system catalog, and orders output with a catalog-derived dependency graph.
- [Supabase CLI](https://swe.quest/articles/supabase-cli-a62c53c7dbec808f.md): Supabase · 2021-03-31 · Medium · 7 min read · Schema migrations, PostgreSQL, Developer tools
  Supabase's new CLI runs the full Supabase stack locally via Docker Compose, using the same tooling as production, and walks through wiring it to a React app.
- [Supabase CLI v1 and Management API Beta](https://swe.quest/articles/supabase-cli-v1-and-management-api-beta-40e0f641270aa760.md): Supabase · 2022-08-15 · Medium · 4 min read · Schema migrations, Developer tools, PostgreSQL, CI/CD, API design
  Supabase CLI v1 leaves beta with commands to manage organizations, projects and Edge Functions, plus database migration tooling, CI/CD workflows and TypeScript type generation.
- [Supabase Local Dev: migrations, branching, and observability](https://swe.quest/articles/supabase-local-dev-migrations-branching-and-observability-770def662fe57683.md): Supabase · 2023-08-08 · Easy · 6 min read · PostgreSQL, Developer tools, Schema migrations, Testing, Deployment
  Supabase's CLI gains a batch of Postgres local-development features: \`supabase inspect db\` with 19 diagnostic commands adapted from Heroku's pg-extras, \`db dump\` backups built on pg\_dump, migration squashing and diffing via migra, pgTAP testing with \`supabase test\`, plpgsql\_check linting, seeding, and TypeScript type generation that now detects foreign-key relationships.
- [The Vibe Coder's Guide to Supabase Environments](https://swe.quest/articles/the-vibe-coder-s-guide-to-supabase-environments-2ce71129a08af138.md): Supabase · 2025-08-17 · Medium · 10 min read · Schema migrations, CI/CD, Deployment, PostgreSQL, Identity & auth
  Separate Supabase projects for development and production, with all schema changes captured as timestamped SQL migrations in a Git-tracked supabase/ directory, keep a fast workflow from breaking live data.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
