Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimwins/langur
A simple database migration tool
https://github.com/jimwins/langur
Last synced: 17 days ago
JSON representation
A simple database migration tool
- Host: GitHub
- URL: https://github.com/jimwins/langur
- Owner: jimwins
- License: mit
- Created: 2024-09-10T01:35:45.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T03:21:54.000Z (2 months ago)
- Last Synced: 2024-09-10T06:20:57.240Z (2 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Langur: a simple database migration tool in PHP
[Langur][langur] is inspired by [dbmate](https://github.com/amacneil/dbmate).
It is a standalone tool and PHP library that can be used to apply migration
scripts to a database.## Features
* Supports any database accessible via PHP's PDO extension.
* Uses plain SQL for migrations
* It does *not* provide any mechanism for make that SQL portable across
different database systems
* Individual migrations are run inside a transaction (by default)
* Can create and drop databases
* Can generate a file of SQL to generate the current schema
* Makes setting up new databases a one-step process instead of running all
migrations
* Diff of full schema provides an additional check for code review## Installation
*TBD*
## Usage
You can run `./vendor/bin/langur --help` to see the full list of commands
options.## Example
The following example demonstrates:
* Creating a migration that creates a new `users` table with a few columns
including a `name` column
* Creating the database and applying that migration
* Creating another migration to add new `first_name` and `last_name` columns to
the `users` table, initializing the data from the `name` column and dropping
the `name` column
* Running that migration
* Rolling back that migration
* Dumping the schema```sh
$ export LANGUR_DSN="sqlite3:example.sqlite"
$ ./vendor/bin/langur new create_users < '' then ' ' || last_name else '' end;
alter table users drop first_name, last_name;
SQL
$ ./vendor/bin/langur migrate
$ sqlite3 example.sqlite3 "select * from users"
$ ./vendor/bin/langur rollback
$ sqlite3 example.sqlite3 "select * from users"
$ ./vendor/bin/langur dump
```## About the langur
Old World monkeys of the genus *[Semnipithecus](https://en.wikipedia.org/wiki/Semnopithecus)*
are more commonly known as *langurs*, and are native to the Indian subcontinent.[Jim Winstead](mailto:[email protected]), September 2024
[langur]: https://trainedmonkey.com/projects/langur/