Published on
Can you put your database on GitHub?
You cannot run a database on GitHub: it stores your code and its history, but it does not keep a PostgreSQL or MySQL server running and accepting connections. What goes into the repository is the definition of the database, such as migrations, the schema and seeds with fake data. The data itself lives in a managed database, on a VPS or in a BaaS, and the app reaches it through an environment variable that never gets committed. This guide explains why a SQLite file in the repository causes trouble in production, compares the price of a small database across five services in dollars and in reais (PTAX of 11/27/2026 plus 3.5% IOF), shows a GitHub Actions workflow with PostgreSQL for tests and covers running migrations on deploy.
Can you put your database on GitHub?
Not as a running database. GitHub hosts Git repositories: files, commit history, pull requests, issues and automation. A database is a process that stays up all the time, accepts connections, writes data on every request and needs backups. None of that happens inside a repository. Even GitHub Pages, which publishes websites from a repository, only serves static files.
What you can do, and should, is keep everything that describes the database in the repository: the migration files that create and change tables, the ORM schema and seed scripts with sample data. That way anyone on the team can rebuild the database from scratch with one command, and every change to the structure goes through a pull request and review like the rest of the code.
The real data lives somewhere else: in a managed database, on a VPS you run yourself or in a ready-made backend service, known as BaaS. The app, deployed from GitHub, finds the database through an environment variable, usually DATABASE_URL, set on the hosting platform and never written in the code.
The limits and prices in this guide were read from the GitHub documentation and from each service's official pages on 11/28/2026. Conversions to Brazilian reais use the selling PTAX rate of 11/27/2026, the latest published by Banco Central on the day we checked, at R$ 5.5430 per dollar, plus the 3.5% IOF tax Brazil charges on international card purchases.
Which parts of the database belong in the repository?
Anything that is text, changes along with the code and can be reviewed in a diff. When someone opens a pull request that adds a column, the reviewer sees the migration next to the code that uses it, and the Git history becomes the story of how the database evolved. In practice, three kinds of files go into the repository.
- Migrations, the numbered files that create tables, columns and indexes in a fixed order. Each tool has its own folder:
prisma/migrationsin Prisma,migrationsin Knex,alembic/versionsin Alembic anddatabase/migrationsin Laravel. - The schema, when your tool uses one, such as Prisma's
schema.prismaor Django and SQLAlchemy models. It is the source of truth for the structure, and migrations are generated from it. - Seeds with fake data, so whoever clones the project gets sample users, products and orders in their local database. Real customer data never goes here, not even half-anonymized.
my-app/
├── prisma/
│ ├── schema.prisma
│ ├── migrations/
│ │ ├── 20261120093000_create_users/migration.sql
│ │ └── 20261127141500_add_orders/migration.sql
│ └── seed.ts
├── .env.example # DATABASE_URL="postgresql://app:password@localhost:5432/app"
└── .gitignore # .env, *.db, *.sqliteIt also pays to commit a .env.example with every variable name and dummy values, and to put the real .env in .gitignore. Whoever clones the repository knows what to configure, and no password travels with it. For local development, a docker run of the official PostgreSQL image, or a docker compose file with the same engine as production, beats any committed database file.
What if I commit the SQLite file to the repository?
It works for a prototype or for a small read-only dataset, such as a sample table in a study project. In a production app that stores user data, a .db file in the repository causes trouble for four separate reasons.
The first is merging. A SQLite file is binary, and Git cannot combine two versions of it. If two branches wrote to the database, the merge becomes a conflict where you pick one whole file and lose whatever was written to the other. There is no diff to review and no way to join the two halves.
The second is size. Git warns you when a file is larger than 50 MiB, GitHub blocks files larger than 100 MiB and browser uploads accept up to 25 MiB. Every commit of the database stores a new copy in the history, so the repository grows with each change even if the table stays the same size. GitHub's own documentation says Git is not designed to handle large SQL files and recommends a file sharing service for large databases.
Git LFS gets you past the file limit by storing the file outside the history, but the free quota on GitHub Free and Pro accounts is 10 GiB of storage and 10 GiB of bandwidth per month. Every clone, every build and every Actions runner that downloads the file uses bandwidth. With a US$ 0 budget, LFS is blocked for the rest of the month once the quota runs out. And LFS does not fix merging.
The third is that the file in the repository is not the production file. The deployed app writes to a copy inside the container, and on most platforms that disk is ephemeral: the next deploy starts again from the file in the commit and throws away whatever users saved. SQLite in production needs a persistent disk and a single writing instance, which in practice means running a database without the tools of one.
The fourth is the most serious: personal data. A database with customer names, emails, tax IDs or phone numbers in a repository gets copied into every clone, every fork and every machine that ever pulled the project. Brazil's data protection law, the LGPD, requires anyone processing personal data to adopt security measures against unauthorized access (art. 46) and to report incidents that may cause relevant risk or harm to the ANPD and to the people affected (art. 48). A repository made public by mistake, with the database inside, is exactly that kind of incident. Other jurisdictions, such as the EU under GDPR, have similar rules.
| GitHub limit | Value on 11/28/2026 |
|---|---|
| Git warning when adding or updating a file | Larger than 50 MiB |
| File blocked by GitHub | Larger than 100 MiB |
| Browser upload | Up to 25 MiB per file |
| Recommended repository size | Ideally under 1 GB, and strongly recommended under 5 GB |
| Git LFS included with GitHub Free and Pro | 10 GiB of storage and 10 GiB of bandwidth |
| LFS overage with a US$ 0 budget | No charge, but LFS is blocked until the end of the month |
Why can't the database password go into the repository?
Because Git keeps everything. A connection string like postgresql://app:password@host:5432/app committed once stays in the history even after a later commit deletes it, and anyone with access to the repository can recover it with git log. If the repository is public, that includes bots that scan GitHub for credentials around the clock.
GitHub helps with secret scanning, which looks for API keys, tokens and passwords across the whole history, in every branch, and also in issues, pull requests, discussions and wikis. On public repositories it runs automatically and for free. On private organization repositories it requires GitHub Secret Protection on the Team or Enterprise Cloud plans. When the secret belongs to a partner provider, GitHub notifies that provider, which can revoke the credential.
Detection of generic passwords and connection strings, however, depends on patterns that must be enabled, so do not count on an alert to protect your database password. The protection that works is not committing it at all: the password lives only in environment variables, .env stays in .gitignore and secret scanning is the safety net.
If the password leaked anyway, order matters. Change the password on the database first, update the variable in every app and workflow that uses it, and only then clean up the history. Rewriting history without changing the password solves nothing, because the credential may already have been copied by anyone who cloned the repository.
So where should the database live?
Somewhere built to run databases, in the same region as your app. There are three common options, and what sets them apart is how much of the work stays with you and how much the provider takes on.
A managed database is the most common choice: you pick the engine and the size, get a host, port, user and password, and the platform handles updates, backups and disk. A VPS gives you more memory per dollar, but installation, security updates, backups and monitoring are on you. A BaaS, such as Supabase or Firebase, bundles the database with authentication, file storage and an API, and makes sense when you want to write less backend code.
The table compares the price of a small production PostgreSQL with 1 GB of data across five services. The setups are not identical, because each service sells databases differently, so read the setup column before comparing the numbers.
| Service | Example setup | Backups | Monthly price | In BRL, with PTAX and 3.5% IOF |
|---|---|---|---|---|
| Supabase | Pro plan with Micro compute (1 GB of RAM) and 8 GB of disk included | Daily, kept for 7 days | US$ 25.00 | R$ 143.43 |
| Neon | Launch plan, 0.25 CU (about 1 GB of RAM) running 730 hours at US$ 0.106 per CU-hour, plus 1 GB at US$ 0.35 | Point-in-time restore of 1 day, extendable to 7 days | US$ 19.70 | R$ 113.02 |
| Render | Postgres 0.1c-256mb (256 MB of RAM), plus 1 GB at US$ 0.30 | Point-in-time recovery of 3 days on the Hobby workspace | US$ 6.30 | R$ 36.14 |
| Railway | Hobby plan, with the database inside the US$ 5 of usage included in the subscription | Scheduled volume backups; the daily one is kept for 6 days | US$ 5.00 | R$ 28.69 |
| Zenifra | DB-Starter (0.3 vCPU and 256 MB of RAM) in São Paulo, plus 1 GB at R$ 0.20 | Every 24 hours, kept for 7 days | R$ 12.10 | R$ 12.10, billed in BRL |
Supabase charges the plan subscription, which already includes 1 GB of RAM and 8 GB of disk, and adds authentication, storage and an API on top of the database. Neon charges per compute hour and can suspend the database after a few idle minutes, which cuts the bill a lot for a rarely used database. On Railway, the bill goes above US$ 5 when the database's memory, CPU and disk usage exceeds the included credit. None of these four has a region in South America.
Free tiers exist, but their limits do not fit production. Supabase Free has 500 MB per project and pauses projects after a week of inactivity. Render's free Postgres expires 30 days after creation, has a fixed 1 GB and no backups. Neon Free has 1 GB per project and 100 CU-hours per month, with the database suspending after 5 idle minutes.
On Zenifra, the database runs in São Paulo, billing is in Brazilian reais by PIX, boleto or card, and the available engines are PostgreSQL 15 to 18, MariaDB, Valkey and ClickHouse. If the database needs more headroom, DB-Basic has 1 vCPU and 1 GB of RAM for R$ 49.90 per month, with backups every 12 hours.
How do you connect a GitHub repository to the database?
Through an environment variable, set in two different places. On the platform where the app runs, you set DATABASE_URL to the database connection string, and the code reads process.env.DATABASE_URL, os.environ or your language's equivalent. The repository only knows the variable name, never its value.
On GitHub, when a workflow needs to talk to the database, for example to run migrations, the same string goes into the repository secrets under Settings, Secrets and variables, Actions. The workflow reads it with ${{ secrets.DATABASE_URL }}, and GitHub masks the secret in logs. One detail that often surprises people: workflows triggered by pull requests from forks do not receive secrets, which protects the database from third-party code.
On Zenifra it works the same way. DATABASE_URL is not injected automatically into HTTP projects: you copy the ready-made URI from the database connection panel and add the variable to the app project. For PostgreSQL, the URI already includes sslmode=require, because TLS is required by default. Public access to the database is on by default, always over TLS, which lets you run migrations from GitHub Actions. If you would rather turn it off, apps in the same organization stay connected through private connections at an internal address.
# Variable on the app project, never in the repository
DATABASE_URL="postgresql://app:<password>@postgresql-<id>.managed.zenifra.com:<port>/app?sslmode=require"When you rotate the database password, update the variable everywhere at once: in every app that uses the database and in the GitHub secret. A forgotten secret is the most common reason a migration workflow that worked yesterday fails today with an authentication error.
How do you test against a real PostgreSQL in GitHub Actions?
With a service container. The workflow's services: block starts a throwaway PostgreSQL next to the job, the tests run against it and everything is deleted when the run ends. You need no external database and no secret, because the password only exists inside that run and is valid nowhere else.
The example follows the format GitHub documents for jobs that run directly on the runner machine: the official Postgres image, a pg_isready health check so the job only starts once the database accepts connections, port 5432 published on the runner and migrations applied before the tests. That way the same command that will run in production is tested on every pull request.
name: tests
on:
pull_request:
push:
branches: [main]
jobs:
tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
DATABASE_URL: postgresql://app:app@localhost:5432/app_test
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- run: npm ci
- run: npx prisma migrate deploy
- run: npm testUse the same PostgreSQL major version you run in production. If production is on PostgreSQL 18, use the postgres:18 image in the workflow, so a migration that passes in tests also passes on deploy. If the app also uses Valkey or MariaDB, the same services: block accepts more than one container in a single job.
How do you run migrations on deploy?
With your tool's production command, never the development one. In Prisma, migrate dev creates new migrations, uses a shadow database and may ask to reset the database, and the documentation says it should never be used in production. The right command is migrate deploy, which only applies pending migrations, does not reset the database and does not rely on a shadow database. The table shows the equivalent in the most common tools.
migrate:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- run: npm ci
- run: npx prisma migrate deploy
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}# Alternative: start command on the app project
npx prisma migrate deploy && node dist/server.js| Tool | Development | Production and CI |
|---|---|---|
| Prisma | npx prisma migrate dev | npx prisma migrate deploy |
| Knex | npx knex migrate:make name | npx knex migrate:latest |
| Alembic (Python) | alembic revision --autogenerate | alembic upgrade head |
| Django | python manage.py makemigrations | python manage.py migrate |
| Laravel | php artisan make:migration | php artisan migrate --force |
There are two common places to run that command. The first is a GitHub Actions job triggered on push to main, after the tests, with DATABASE_URL stored in secrets. The second is the app's own start command, which applies migrations and only then starts the server. The second option does not require exposing the database to GitHub, and Prisma takes a lock on the database so two instances starting at the same time do not apply the same migration twice.
With automatic deploys per branch, the platform starts deploying on the same push that triggers the workflow, so the migration job may finish after the new version is live, or before. Write migrations that work with both versions of the code: add the column in one deploy, start using it in the next and drop the old one only when no code reads it. If you want a strict order, deploy by tag or release and create the tag after the job finishes.
A word of caution about preview environments: on Zenifra, the Preview for each pull request inherits the main project's variables and does not copy the database. If migrations run in the start command and DATABASE_URL points to production, the preview applies a migration from unapproved code to the production database. The safe pattern is to enable previews on a staging project with a test database.
Can GitHub Pages run a backend with a database?
No. GitHub Pages publishes HTML, CSS and JavaScript straight from the repository, with a 1 GB limit per site and a soft bandwidth limit of 100 GB per month. There is no server running Node.js, Python or PHP, so there is nowhere to run database queries safely.
A front end on Pages can call an API hosted somewhere else, but the database password can never go into browser JavaScript, because any visitor can read it in the developer tools. GitHub's documentation also says Pages should not be used for sensitive transactions such as sending passwords or credit card numbers, nor as free hosting for an online business.
When the project needs a backend, the answer is to deploy the app from the same repository to a platform that runs processes. The GitHub deploy guide walks through it on Zenifra, with runtime, commands and variables, and the comparison of platforms with managed databases and AI helps you choose where to host.
In short
GitHub stores the code of your database, not the database. Version migrations, the schema, seeds with fake data and a .env.example, keep the SQLite file and .env out of the repository, and store the connection string as a variable on your host and as a secret in GitHub Actions. The data goes to a managed database, a VPS or a BaaS, with backups and in the same region as the app. For tests, a PostgreSQL service container does the job without an external database, and on deploy you use your tool's production command, such as prisma migrate deploy.
If your app serves users in Brazil, a database in São Paulo billed in reais is a good place to start: on Zenifra, PostgreSQL on DB-Starter costs R$ 12.10 per month with 1 GB, and apps start at R$ 5.90.