Skip to content

Schema Builder

Database

Database: Schema Builder

Introduction

Each database spells CREATE TABLE and ALTER TABLE a little differently, so a table written in SQL for PostgreSQL may not run on the SQLite database on a teammate's laptop. Laravel's schema builder lets you describe your tables, columns, and indexes once in Go. Laravel then writes the SQL for your database, so the same code runs on PostgreSQL, MySQL, MariaDB, and SQLite.

You'll use the schema builder in migrations most of the time. The functions of the schema package change the tables of the database that ctx runs on, which in a migration is the migration's transaction. For example, this migration passes schema.Create a function that describes a posts table:

1// database/migrations/2026_11_10_120000_create_posts_table.go
2package migrations
3 
4import (
5 "context"
6 
7 "go.laravel.com/schema"
8)
9 
10func createPostsTable(ctx context.Context) error {
11 return schema.Create(ctx, "posts", func(table *schema.Blueprint) {
12 table.ID()
13 table.ForeignID("user_id").Constrained().CascadeOnDelete()
14 table.String("title")
15 table.String("slug").Unique()
16 table.Text("body").Nullable()
17 table.Timestamp("published_at").Nullable()
18 table.Timestamps()
19 
20 table.Index("user_id", "published_at")
21 })
22}
1// database/migrations/2026_11_10_120000_create_posts_table.go
2package migrations
3 
4import (
5 "context"
6 
7 "go.laravel.com/schema"
8)
9 
10func createPostsTable(ctx context.Context) error {
11 return schema.Create(ctx, "posts", func(table *schema.Blueprint) {
12 table.ID()
13 table.ForeignID("user_id").Constrained().CascadeOnDelete()
14 table.String("title")
15 table.String("slug").Unique()
16 table.Text("body").Nullable()
17 table.Timestamp("published_at").Nullable()
18 table.Timestamps()
19 
20 table.Index("user_id", "published_at")
21 })
22}

Each function in the schema package runs its change as soon as you call it and returns an error, so a migration that makes several changes checks each error before it makes the next change:

1if err := schema.DropIfExists(ctx, "drafts"); err != nil {
2 return err
3}
4 
5return schema.Rename(ctx, "articles", "posts")
1if err := schema.DropIfExists(ctx, "drafts"); err != nil {
2 return err
3}
4 
5return schema.Rename(ctx, "articles", "posts")

Tables

Creating tables

To create a new table, pass schema.Create the table's name and a function. The function receives a *schema.Blueprint, and you add the table's columns, indexes, and foreign keys to the blueprint:

1return schema.Create(ctx, "flights", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("name")
4 table.String("airline")
5 table.Timestamps()
6})
1return schema.Create(ctx, "flights", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("name")
4 table.String("airline")
5 table.Timestamps()
6})

Changing tables

To change a table that already exists, call schema.Alter with the same kind of function. Alter adds each column you define to the table, while methods such as RenameColumn and DropColumn change the columns the table already has:

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.Integer("votes").Default(0)
3 table.RenameColumn("bio", "about")
4 table.DropColumn("legacy_flags")
5})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.Integer("votes").Default(0)
3 table.RenameColumn("bio", "about")
4 table.DropColumn("legacy_flags")
5})

SQLite can't make some changes in place, such as changing or dropping a column or adding a foreign key. For those changes, Laravel rebuilds the table for you and keeps its rows and indexes.

Renaming and dropping tables

To give a table a new name, call schema.Rename. To delete a table and its rows, call schema.Drop or schema.DropIfExists:

1if err := schema.Rename(ctx, "articles", "posts"); err != nil {
2 return err
3}
4 
5return schema.Drop(ctx, "legacy_posts")
1if err := schema.Rename(ctx, "articles", "posts"); err != nil {
2 return err
3}
4 
5return schema.Drop(ctx, "legacy_posts")

Drop returns an error when the table doesn't exist, and DropIfExists doesn't. Renaming a table doesn't rename its indexes or foreign keys, so a later migration drops them by their old names, such as articles_user_id_foreign.

Table options

You may set these options on the blueprint in Create. MySQL and MariaDB use all of them, and other databases ignore the options they don't support:

Method Effect
table.Temporary() Creates a temporary table, which only this database session sees
table.Engine("InnoDB") Sets the MySQL and MariaDB storage engine
table.Charset("utf8mb4") Sets the MySQL and MariaDB default character set
table.Collation("utf8mb4_unicode_ci") Sets the MySQL and MariaDB default collation
table.Comment("Blog posts") Adds a comment on PostgreSQL, MySQL, and MariaDB. It works in Alter too

Columns

Column types

The blueprint has a method for each common column type. Unless the method is shown with (), it takes the column's name:

Method Column
ID() An auto-incrementing big integer primary key named id
Increments, BigIncrements, MediumIncrements, SmallIncrements, TinyIncrements An auto-incrementing integer primary key of that size
Integer, BigInteger, MediumInteger, SmallInteger, TinyInteger An integer of that size
Float, Double A floating-point number
Decimal(name, total, places) An exact decimal with total digits, places of them after the decimal point
Boolean A boolean
Char, String Text of up to 255 characters. Set another length with .Length(n)
TinyText, Text, MediumText, LongText Longer text. Only MySQL and MariaDB distinguish the sizes
Enum(name, "draft", "published") Text that must be one of the listed values
Set(name, "parking", "wifi") Any number of the listed values, on MySQL and MariaDB
JSON, JSONB A JSON document. Only PostgreSQL distinguishes JSONB
Date, Time, TimeTZ A calendar date or a time of day. Only PostgreSQL stores the time zone of TimeTZ
DateTime A wall-clock date and time without a time zone, such as an appointment at 9:00 wherever it takes place
Timestamp A moment in time, which Laravel writes in UTC: timestamp on PostgreSQL, and datetime on MySQL, MariaDB, and SQLite
Timestamps() Nullable created_at and updated_at timestamps
SoftDeletes() A nullable deleted_at timestamp
Year A year
Binary Binary data
UUID, ULID A UUID or ULID
ForeignID, ForeignUUID, ForeignULID A key of another table, ready for a foreign key
IPAddress, MACAddress A network address
Geometry, Geography A spatial value. PostgreSQL needs the PostGIS extension
Vector(name, dimensions) A fixed-length embedding for vector columns
Morphs, UUIDMorphs, ULIDMorphs, and their Nullable forms {name}_type and {name}_id columns with an index on both
RememberToken() A nullable remember_token of 100 characters

Each column reads into the same Go type on every database, whether you scan it into a model or your own struct:

Columns Go type
ID, ForeignID, and the integers int64, or a smaller integer such as int32
Float, Double float64
Decimal numeric.Decimal, so no digits are lost
Boolean bool
Char, String, the text types, Enum, Set, ULID, and MACAddress string
UUID, ForeignUUID uuid.UUID, from the standard library's uuid package
IPAddress netip.Addr, from net/netip
JSON, JSONB Your own type in db.JSON, or string or []byte
Date date.Date, or time.Time
DateTime, Timestamp, and the columns of Timestamps() and SoftDeletes() time.Time
Time, TimeTZ string
Year int64
Binary []byte
Vector db.Vector

When a column is .Nullable(), read it into a pointer to its type, such as *string or *time.Time. The pointer is nil when the column holds NULL.

Column modifiers

Columns are not null unless you say otherwise. To change a column's definition, chain modifiers onto the column. For example, this column holds up to 50 characters, allows NULL, and has a comment:

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.String("nickname").Length(50).Nullable().Comment("Shown next to posts")
3})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.String("nickname").Length(50).Nullable().Comment("Shown next to posts")
3})
Modifier Effect
.Nullable() Allows NULL
.Default(value) Sets the column's default value for an insert that leaves it out
.UseCurrent() Defaults a date or time column to the current time
.UseCurrentOnUpdate() On MySQL and MariaDB, sets a timestamp to the current time whenever its row changes
.StoredAs(expr), .VirtualAs(expr) Defines a generated column
.Unsigned() Makes a number unsigned on MySQL and MariaDB
.AutoIncrement() Makes an integer auto-incrementing, which also makes it the primary key
.StartingValue(1000) Sets the first value of an auto-incrementing column on PostgreSQL, MySQL, and MariaDB
.Length(n) Sets the length of a String, Char, or Binary column
.Precision(n) Sets the fractional digits of seconds a time column keeps, in place of the connection's time precision, or the bits of a Float
.Comment(text) Adds a comment on PostgreSQL, MySQL, and MariaDB
.Charset(name), .Collation(name) Sets a text column's character set on MySQL and MariaDB, or its collation
.After(column), .First() Places a new column on MySQL and MariaDB
.Invisible() Leaves the column out of select * on MySQL and MariaDB
.Instant(), .Lock(schema.LockNone) On MySQL and MariaDB, changes a large table without copying its rows or blocking writes
.Primary(), .Unique(), .Index(), .FullText(), .SpatialIndex() Adds an index on the column

To add several columns after a given column on MySQL or MariaDB, such as the lines of an address after password, define them inside table.After. Each column goes right after the column before it, so the columns keep the order you write them in. Other databases add the columns at the end of the table:

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.After("password", func(table *schema.Blueprint) {
3 table.String("address_line1")
4 table.String("address_line2").Nullable()
5 table.String("city")
6 })
7})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.After("password", func(table *schema.Blueprint) {
3 table.String("address_line1")
4 table.String("address_line2").Nullable()
5 table.String("city")
6 })
7})

Defaults

A default fills a column when an insert leaves the column out. .Default takes a string, a number, a bool, or a raw expression from db.Raw. Laravel escapes a string, number, or bool as a literal for your database, and copies a db.Raw expression into the SQL exactly as you wrote it:

1return schema.Create(ctx, "flights", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("status").Default("scheduled")
4 table.Integer("seats").Default(180)
5 table.Boolean("international").Default(false)
6 table.JSON("movies").Default("[]")
7 table.Date("booked_on").Default(db.Raw("(current_date)"))
8})
1return schema.Create(ctx, "flights", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("status").Default("scheduled")
4 table.Integer("seats").Default(180)
5 table.Boolean("international").Default(false)
6 table.JSON("movies").Default("[]")
7 table.Date("booked_on").Default(db.Raw("(current_date)"))
8})

MySQL accepts an expression default only in parentheses, such as (current_date) in this example, and PostgreSQL and SQLite accept the parentheses too.

For a model to leave a column out of its insert so the database's default applies, tag the model's field db:",default".

Generated columns

Sometimes a column's value always follows from other columns in the same row, such as a line item's total. A generated column lets the database compute that value for you. Pass the SQL expression to StoredAs or VirtualAs:

1return schema.Create(ctx, "line_items", func(table *schema.Blueprint) {
2 table.ID()
3 table.Integer("price")
4 table.Integer("quantity")
5 table.Integer("total").StoredAs("price * quantity")
6})
1return schema.Create(ctx, "line_items", func(table *schema.Blueprint) {
2 table.ID()
3 table.Integer("price")
4 table.Integer("quantity")
5 table.Integer("total").StoredAs("price * quantity")
6})

StoredAs computes the value whenever a row is inserted or updated, and stores the value in the table. VirtualAs computes the value each time you read the column, and needs PostgreSQL 18 or later on PostgreSQL.

Changing columns

To change an existing column's type or modifiers, define the column again in Alter and end the chain with .Change():

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.String("name").Length(100).Nullable().Change()
3})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.String("name").Length(100).Nullable().Change()
3})

The new definition replaces the old one, so list every modifier the column should keep. For example, a nullable column that you don't mark .Nullable() again becomes not null.

When PostgreSQL can't convert a column's existing values to the new type on its own, pass a cast to .Using:

1table.Date("birthday").Change().Using("birthday::date")
1table.Date("birthday").Change().Using("birthday::date")

Renaming and dropping columns

To rename or remove columns, call RenameColumn and DropColumn in Alter:

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.RenameColumn("bio", "about")
3 table.DropColumn("legacy_flags", "legacy_notes")
4})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.RenameColumn("bio", "about")
3 table.DropColumn("legacy_flags", "legacy_notes")
4})

DropColumn takes one name or several, and also drops the indexes on those columns. You may also call DropTimestamps, DropSoftDeletes, DropRememberToken, and DropMorphs to drop the columns that Timestamps, SoftDeletes, RememberToken, and Morphs add.

Indexes

Creating indexes

An index lets the database find rows without reading the whole table, and a unique index also refuses a second row with the same value. You may add an index on one column with a column modifier, or an index on several columns with a blueprint method:

1return schema.Create(ctx, "users", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("email").Unique()
4 table.ForeignID("team_id")
5 table.Timestamps()
6 
7 table.Index("team_id", "created_at")
8})
1return schema.Create(ctx, "users", func(table *schema.Blueprint) {
2 table.ID()
3 table.String("email").Unique()
4 table.ForeignID("team_id")
5 table.Timestamps()
6 
7 table.Index("team_id", "created_at")
8})
Method Index
Primary(columns...) The primary key
Unique(columns...) A unique index
Index(columns...) An index
FullText(columns...) A full-text index for a full-text search, on PostgreSQL, MySQL, and MariaDB
SpatialIndex(columns...) A spatial index on a Geometry or Geography column, except on SQLite
VectorIndex(column) A cosine-distance index for vector similarity search, on PostgreSQL and MariaDB

Laravel names an index {table}_{columns}_{kind}, such as users_email_unique or users_team_id_created_at_index. To give an index another name, call .Name:

1table.Unique("team_id", "email").Name("users_team_email_unique")
1table.Unique("team_id", "email").Name("users_team_email_unique")

To choose an index algorithm, such as gin for a PostgreSQL JSONB column, call .Algorithm:

1table.Index("attributes").Algorithm("gin")
1table.Index("attributes").Algorithm("gin")

On PostgreSQL, a full-text index uses the english text search configuration by default. To use another configuration, call .Language("simple") on the index, and give your full-text search the same language so the search can use the index.

Renaming and dropping indexes

To drop or rename an index, pass the index's name in Alter:

1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.DropUnique("users_email_unique")
3 table.DropIndex("users_team_id_created_at_index")
4 table.RenameIndex("users_name_index", "users_display_name_index")
5})
1return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
2 table.DropUnique("users_email_unique")
3 table.DropIndex("users_team_id_created_at_index")
4 table.RenameIndex("users_name_index", "users_display_name_index")
5})

Use the drop method that matches the kind of index: DropUnique for a unique index, DropFullText, DropSpatialIndex, or DropVectorIndex for those kinds, and DropIndex for a plain index. DropPrimary() takes no arguments, because a table has only one primary key.

Foreign keys

A foreign key makes the database check that a row's key refers to a row that exists. For example, every post belongs to a user, so a post's user_id should always match a user's id. Constrained adds a foreign key to a key column, and finds the referenced table from the column's name, so user_id references id on users:

1return schema.Create(ctx, "posts", func(table *schema.Blueprint) {
2 table.ID()
3 table.ForeignID("user_id").Constrained().CascadeOnDelete()
4})
1return schema.Create(ctx, "posts", func(table *schema.Blueprint) {
2 table.ID()
3 table.ForeignID("user_id").Constrained().CascadeOnDelete()
4})

When the column's name doesn't match the table, call References with the table's name, and the referenced column if it isn't id. To add a foreign key on columns you've already defined, such as a key made of several columns, pass the columns to Foreign. Chain column modifiers such as .Nullable() before Constrained or References, because those methods return the foreign key rather than the column:

1table.ForeignID("author_id").Nullable().References("users").NullOnDelete()
2table.ForeignUUID("team_uuid").References("teams", "uuid")
3table.Foreign("order_number").References("orders", "number").CascadeOnUpdate()
1table.ForeignID("author_id").Nullable().References("users").NullOnDelete()
2table.ForeignUUID("team_uuid").References("teams", "uuid")
3table.Foreign("order_number").References("orders", "number").CascadeOnUpdate()

When the referenced row is deleted or its key changes, the database needs to know what to do with the rows that refer to it. Choose with these methods:

Method Effect
CascadeOnDelete(), CascadeOnUpdate() Deletes the row, or changes its key
RestrictOnDelete(), RestrictOnUpdate() Refuses the change
NullOnDelete(), NullOnUpdate() Sets the key to NULL
NoActionOnDelete(), NoActionOnUpdate() Refuses the change, checked at the end of the statement

Laravel names a foreign key {table}_{columns}_foreign, such as posts_user_id_foreign, and you may give it another name with .Name. To drop a foreign key, pass its name to DropForeign. To drop a foreign key and its column together, call DropConstrainedForeignID with the column's name:

1table.DropForeign("posts_user_id_foreign")
2table.DropConstrainedForeignID("author_id")
1table.DropForeign("posts_user_id_foreign")
2table.DropConstrainedForeignID("author_id")

Turning foreign key checks off

When you clear or seed related tables, foreign keys force an order on you. For example, you'd have to delete the comments before the posts they belong to. schema.WithoutForeignKeyConstraints runs your function in a transaction with foreign key checks off, and turns the checks back on when the transaction ends, even if your function returns an error. You may call it in a migration, a seeder, or a console command:

1err := schema.WithoutForeignKeyConstraints(ctx, func(ctx context.Context) error {
2 if _, err := db.Table("posts").Delete(ctx); err != nil {
3 return err
4 }
5 
6 _, err := db.Table("comments").Delete(ctx)
7 
8 return err
9})
1err := schema.WithoutForeignKeyConstraints(ctx, func(ctx context.Context) error {
2 if _, err := db.Table("posts").Delete(ctx); err != nil {
3 return err
4 }
5 
6 _, err := db.Table("comments").Delete(ctx)
7 
8 return err
9})

Run the queries inside with the function's ctx, because the checks are off only on the transaction's connection.

On PostgreSQL and SQLite, every reference must be valid again by the time your function returns. SQLite checks every reference before the commit. PostgreSQL can't turn checks off, so it only delays the checks of foreign keys created with .Deferrable() until the commit:

1table.ForeignID("post_id").Constrained().Deferrable()
1table.ForeignID("post_id").Constrained().Deferrable()

Check constraints

A check constraint is a condition every row must meet, such as a product price that's never negative. The database refuses any insert or update that breaks the condition, no matter which code writes the row. Give the check a name, and write its condition in SQL:

1return schema.Create(ctx, "products", func(table *schema.Blueprint) {
2 table.ID()
3 table.Decimal("price", 8, 2)
4 table.Check("products_price_check", "price >= 0")
5})
1return schema.Create(ctx, "products", func(table *schema.Blueprint) {
2 table.ID()
3 table.Decimal("price", 8, 2)
4 table.Check("products_price_check", "price >= 0")
5})

A check's condition can't take bound arguments, so write each value into the SQL. To remove a check, pass its name to table.DropCheck("products_price_check") in Alter.

Vector columns

If your application searches documents by meaning, such as finding help articles similar to a user's question, you'll store an embedding for each document in a vector column. A vector column holds the number of dimensions your AI model's embeddings have, and works with vector similarity queries. Vector columns work on PostgreSQL with the pgvector extension, and on MariaDB 11.7 or later.

On PostgreSQL, schema.EnsureVectorExtension installs pgvector if the database doesn't have the extension yet. MariaDB has vectors built in, so on MariaDB the function does nothing:

1func createDocumentsTable(ctx context.Context) error {
2 if err := schema.EnsureVectorExtension(ctx); err != nil {
3 return err
4 }
5 
6 return schema.Create(ctx, "documents", func(table *schema.Blueprint) {
7 table.ID()
8 table.String("title")
9 table.Vector("embedding", 1536).Index()
10 })
11}
1func createDocumentsTable(ctx context.Context) error {
2 if err := schema.EnsureVectorExtension(ctx); err != nil {
3 return err
4 }
5 
6 return schema.Create(ctx, "documents", func(table *schema.Blueprint) {
7 table.ID()
8 table.String("title")
9 table.Vector("embedding", 1536).Index()
10 })
11}

Calling .Index() on a vector column adds a cosine-distance index, so similarity searches don't read every row. To index a vector column that already exists, call table.VectorIndex("embedding") in Alter rather than table.Index("embedding"). MariaDB indexes at most one vector column per table, and the column must be not null.

Changing large tables

A change that finishes at once on a new table can block a busy production table for minutes, while the database copies its rows or holds a lock on it. PostgreSQL, MySQL, and MariaDB each offer options that keep a table available while you change it.

On PostgreSQL, building an index blocks writes to the table until the index is ready. Call .Online() to build the index concurrently, so writes continue. PostgreSQL can't build an index concurrently inside a transaction, so set NoTransaction on the migration's entry in All to run the migration without a transaction. Other databases ignore .Online():

1// database/migrations/migrations.go
2var All = []db.Migration{
3 // ...
4 {Name: "2026_11_12_090000_index_users_last_seen_at", Run: indexUsersLastSeenAt, NoTransaction: true},
5}
1// database/migrations/migrations.go
2var All = []db.Migration{
3 // ...
4 {Name: "2026_11_12_090000_index_users_last_seen_at", Run: indexUsersLastSeenAt, NoTransaction: true},
5}
1// database/migrations/2026_11_12_090000_index_users_last_seen_at.go
2func indexUsersLastSeenAt(ctx context.Context) error {
3 return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
4 table.Index("last_seen_at").Online()
5 })
6}
1// database/migrations/2026_11_12_090000_index_users_last_seen_at.go
2func indexUsersLastSeenAt(ctx context.Context) error {
3 return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
4 table.Index("last_seen_at").Online()
5 })
6}

On MySQL and MariaDB, .Instant() adds, changes, or drops a column by changing only the table's metadata, without copying its rows. .Lock(...) on a column, an index, or a foreign key sets the strongest lock the database may take while it makes the change: schema.LockNone lets reads and writes go on, and schema.LockShared lets reads go on while writes wait. If the database can't make the change within those limits, the statement fails rather than copy or lock the table, so you find out before a deploy stalls. Other databases ignore both:

1return schema.Alter(ctx, "orders", func(table *schema.Blueprint) {
2 table.String("coupon").Nullable().Instant()
3 table.Index("coupon").Lock(schema.LockNone)
4 table.DropColumn("legacy_notes").Instant()
5})
1return schema.Alter(ctx, "orders", func(table *schema.Blueprint) {
2 table.String("coupon").Nullable().Instant()
3 table.Index("coupon").Lock(schema.LockNone)
4 table.DropColumn("legacy_notes").Instant()
5})

Inspecting the schema

Sometimes a migration needs to know what the database already has, such as whether an earlier deploy added a column by hand. schema.HasTable and schema.HasColumn read the database's current schema:

1has, err := schema.HasColumn(ctx, "users", "email")
2if err != nil {
3 return err
4}
5if !has {
6 return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
7 table.String("email").Nullable()
8 })
9}
10 
11return nil
1has, err := schema.HasColumn(ctx, "users", "email")
2if err != nil {
3 return err
4}
5if !has {
6 return schema.Alter(ctx, "users", func(table *schema.Blueprint) {
7 table.String("email").Nullable()
8 })
9}
10 
11return nil

The schema package has these functions for reading the database's schema:

Function Returns
HasTable(ctx, table) Whether the table exists
HasColumn(ctx, table, column), HasColumns(ctx, table, columns...) Whether the table has the column, or every one of the columns
HasView(ctx, view) Whether the view exists
HasIndex(ctx, table, nameOrColumns...), HasUnique(...) Whether the table has an index, or a unique index, with that name or on those columns in order
Tables(ctx), Views(ctx) The database's tables and views
Columns(ctx, table), Indexes(ctx, table), ForeignKeys(ctx, table) The table's columns, indexes, and foreign keys
Types(ctx) A PostgreSQL database's own types, such as its enums

Columns returns each column's type and default as the database reports them, so the same column reads differently on PostgreSQL, MySQL, MariaDB, and SQLite.