https://github.com/robbycbennett/migrate
Portable database migration shell script
https://github.com/robbycbennett/migrate
database-management database-migrations personal script
Last synced: 11 months ago
JSON representation
Portable database migration shell script
- Host: GitHub
- URL: https://github.com/robbycbennett/migrate
- Owner: RobbyCBennett
- License: mit
- Created: 2023-04-01T15:13:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-13T17:51:11.000Z (over 2 years ago)
- Last Synced: 2025-01-30T05:42:37.698Z (about 1 year ago)
- Topics: database-management, database-migrations, personal, script
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Migrate
Portable database migration shell script
# 🧠Design Philosophy
* Simple to use and portable
* Migrate up/down multiple times with one command
* Review each migration if you want to
* Extensible via the environment script
# 📥 Installation
Clone the repository, which includes the migrate script, and an example environment script for PostgreSQL
Create an environment script and edit it, especially `migration_sql_dir`, `database`, and `user`
```sh
cd MY_EXISTING_REPO_HERE
git submodule add git@github.com:RobbyCBennett/migrate.git
cd migrate
cp .env.postgresql.sh .env.sh
edit .env.sh
```
# 📚 Help
```sh
./migrate.sh
```
```
Migration help
Usage:
./migrate.sh MIG_NAME
./migrate.sh up EXTRA_ARGS
./migrate.sh down EXTRA_ARGS
Examples:
./migrate.sh init
./migrate.sh create_users_table
./migrate.sh up
./migrate.sh up 2
./migrate.sh down 3 yes
./migrate.sh status
Primary Arguments:
init: Initialize the database and create the migrations table
MIG_NAME: Create a migration (usually snake_case) with the given migration name
up: Use a migration to change the database
down: Undo a migration to change the database back
status: Get the status of all migrations
Extra Arguments (EXTRA_ARGS):
yes: Ignore confirmation for each migration (dangerous)
INTEGER: Instead of only 1 migration, migrate up/down many times
Tips:
Folders: Organize SQL files into folders if you want to
```