Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/violetbuse/storch
A db schema migration library for gleam + sqlight
https://github.com/violetbuse/storch
gleam migrations sqlight sqlite
Last synced: about 1 month ago
JSON representation
A db schema migration library for gleam + sqlight
- Host: GitHub
- URL: https://github.com/violetbuse/storch
- Owner: VioletBuse
- Created: 2024-05-29T14:39:12.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-06-28T16:50:17.000Z (6 months ago)
- Last Synced: 2024-11-20T13:56:45.978Z (about 2 months ago)
- Topics: gleam, migrations, sqlight, sqlite
- Language: Gleam
- Homepage: https://hexdocs.pm/storch/
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# storch
[![Package Version](https://img.shields.io/hexpm/v/storch)](https://hex.pm/packages/storch)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/storch/)**This package is superceded by the [feather](https://hex.pm/packages/feather) package, which offers a superset of storch's functionality**
```sh
gleam add storch
```Add the following fields to your gleam.toml file:
```toml
# this can of course be anything you like
migrations_dir = "./priv/migrations"
schemafile = "./schema.sql"
```Then run the command `gleam run -m storch -- new "Initial schema migration"` and make any changes you like.
Running the command `gleam run -m storch -- schema` will create the file ./schema.sql, (or whatever you set in your gleam.toml) with the schema of your database after all migrations have been applied.
```gleam
import storch
import gleam/result
import gleam/erlang
import sqlightpub fn main() {
let assert Ok(priv_dir) = erlang.priv_directory("my_module_name")
use migrations <- result.try(storch.get_migrations(priv_dir <> "/migrations"))
use connection <- sqlight.with_connection(":memory:")
storch.migrate(migrations, on: connection)
}
```Further documentation can be found at .
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```