Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mveytsman/ecto_view_migrations
View migrations for Ecto! 🪟
https://github.com/mveytsman/ecto_view_migrations
Last synced: 28 days ago
JSON representation
View migrations for Ecto! 🪟
- Host: GitHub
- URL: https://github.com/mveytsman/ecto_view_migrations
- Owner: mveytsman
- License: mit
- Created: 2023-02-09T22:14:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-20T22:35:06.000Z (about 1 year ago)
- Last Synced: 2024-04-14T05:51:50.524Z (7 months ago)
- Language: Elixir
- Homepage:
- Size: 11.7 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ecto ViewMigrations
Database views are a powerful tool, but it can be hard to fit them into your Ecto migrations.
This tool provides a generator to create migrations for views that are written directly in SQL.
## Usage
```bash
mix ecto.gen.view_migration my_view_name
```This will generate two files:
- `priv/repo/migrations/[TIMESTAMP]_load_sql_my_view_name.exs`
- `priv/repo/sql/my_view_name_[TIMESTAMP].sql`You write your view in the `.sql` file and the autogenerated migration will handle loading it and dropping it on revert.
If you are changing an existing view, the migration generator will detect this and load the old version on revert accordingly.
## Future WorkNote that, at least in Postgres, `create or replace view` lets you modify the query not the columns. We will want to let the user specify `alter view` or some other mechanism if they need to add or delete columns. Currently, you'd have to do this by hand in the migration.
## InstallationThe package can be installed by adding `ecto_view_migrations` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:ecto_view_migrations, "~> 0.1.0"}
]
end
```Documentation can be at .