All Projects → surgeventures → strong_migrations

surgeventures / strong_migrations

Licence: MIT license
Catch unsafe migrations in your Elixir application

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to strong migrations

Laravel Migrate Fresh
An artisan command to build up a database from scratch
Stars: ✭ 179 (+208.62%)
Mutual labels:  migrations
fat ecto
Query mechanism for Ecto
Stars: ✭ 20 (-65.52%)
Mutual labels:  ecto
query builder
Compose Ecto queries without effort
Stars: ✭ 56 (-3.45%)
Mutual labels:  ecto
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+3891.38%)
Mutual labels:  migrations
elastic-migrations
Elasticsearch migrations for Laravel
Stars: ✭ 153 (+163.79%)
Mutual labels:  migrations
absinthe error payload
Bridges the gap between Ecto and Absinthe for mutation payload
Stars: ✭ 102 (+75.86%)
Mutual labels:  ecto
Django Swappable Models
Swapper - The unofficial Django swappable models API.
Stars: ✭ 169 (+191.38%)
Mutual labels:  migrations
ex operation
A library for making domain operations in Elixir
Stars: ✭ 33 (-43.1%)
Mutual labels:  ecto
ecto erd
A mix task for generating Entity Relationship Diagram from Ecto schemas available in your project.
Stars: ✭ 173 (+198.28%)
Mutual labels:  ecto
gloat
Next-gen database migrations framework for Go.
Stars: ✭ 15 (-74.14%)
Mutual labels:  migrations
Secondbase
Seamless second database integration for Rails.
Stars: ✭ 216 (+272.41%)
Mutual labels:  migrations
Peewee migrate
Simple migration engine for Peewee
Stars: ✭ 250 (+331.03%)
Mutual labels:  migrations
ecto shorts
Shortcuts for ecto
Stars: ✭ 81 (+39.66%)
Mutual labels:  ecto
Cli
The Sequelize CLI
Stars: ✭ 2,248 (+3775.86%)
Mutual labels:  migrations
underbase
MongoDB schema and data migration library based on semver
Stars: ✭ 19 (-67.24%)
Mutual labels:  migrations
Typeorm Nestjs Migration Example
"Example of how to use migrations feature of TypeORM with NestJS.
Stars: ✭ 176 (+203.45%)
Mutual labels:  migrations
MoalemYar
A personal project for class management, using various technologies like WPF, Entityframwork, CodeFirst, Sqlite, Migration and more
Stars: ✭ 53 (-8.62%)
Mutual labels:  migrations
apistar alembic migrations
Alembic migrations for apistar
Stars: ✭ 18 (-68.97%)
Mutual labels:  migrations
migrations
Migrations is a database migration tool that uses go's database/sql from the standard library
Stars: ✭ 17 (-70.69%)
Mutual labels:  migrations
prometheus-ecto
Prometheus.io collector for Elixir.Ecto
Stars: ✭ 74 (+27.59%)
Mutual labels:  ecto

StrongMigrations

Build Status Module Version Hex Docs Total Download License Last Updated

Catch unsafe migrations in your Elixir application

Table of Contents

What is it

strong_migrations is a library that protects your application from invoking unsafe migrations, they needs to be marked as a safe.

  1. Analyze migrations if they are safe.
  2. If migrations are unsafe -> print errors.
  3. If migrations are safe -> use ecto.migrate.

You can also use a macro of StrongMigrations like safety_assured to be sure it's safe and you can run migrations with specific changes. Example

defmodule SafetyAssuredDropTable do
  @moduledoc false

  use StrongMigrations

  def change do
    safety_assured do
      drop(table(:users))
    end
  end
end

Features

  • checking if your migrations are adding an index concurrently in transaction
  • checking if your migrations are adding an index but not concurrently
  • checking if your migrations are removing an index concurrently in transaction
  • checking if your migrations are renaming columns (it's always better to remove old and add new column)
  • checking if your migrations are removing columns
  • checking if your migrations are removing tables
  • mark safety assured do: drop table(:posts) or multiline when you're sure it's safe
  • check if default is a function when altering a table ... tbd

How to install

The package can be installed by adding strong_migrations to your list of dependencies in mix.exs as follows. Also, it's worth adding an alias like: ecto.migrate -> strong_migrations.migrate and thanks to that you'll be sure that all migrations were checked before running.

Update your mix.exs:

def deps do
  [
    {:strong_migrations, "~> 0.1"}
  ]
end

Optionally, you can add an alias:

"ecto.migrate": "strong_migrations.migrate"

And, another option is to use StrongMigrations as a default for generated migrations. Just add following line to your config.exs file.

config :ecto_sql, migration_module: StrongMigrations

How to configure

If you want to specify which classifiers you want to use, please add to your config.exs following lines

config :strong_migrations,
  classifiers: [
    StrongMigrations.Classifiers.AddIndexConcurrentlyInTransaction,
    StrongMigrations.Classifiers.AddIndexNotConcurrently,
    StrongMigrations.Classifiers.DropIndexConcurrentlyInTransaction,
    StrongMigrations.Classifiers.DropTable,
    StrongMigrations.Classifiers.RemoveColumn,
    StrongMigrations.Classifiers.RenameColumn,
    StrongMigrations.Classifiers.DefaultIsFunction
  ]

If you want to specify migration paths available in your project (not default -> priv/repo/migrations), please add to your config.exs following lines

config :strong_migrations,
  migration_paths: [
    "priv/repo/migrations",
    "apps/*/priv/repo/migrations",
    "my/fancy/path/to/migrations"
  ],

Similar Packages

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].