Packages

Multi-tenancy library for Elixir/Phoenix with schema-based isolation (PostgreSQL Schemas or MySQL Databases). Lightweight, observable, with clean separation of concerns.

Current section

Files

Jump to
kirayedar priv templates kirayedar.setup migration.ex.eex
Raw

priv/templates/kirayedar.setup/migration.ex.eex

defmodule <%= @app_module %>.Repo.Migrations.Create<%= String.capitalize(@table) %> do
use Ecto.Migration
def change do
create table(:<%= @table %><%= if @use_binary_id, do: ", primary_key: false" %>) do
<%= if @use_binary_id do %>add :id, :binary_id, primary_key: true<% end %>
add :name, :string, null: false
add :slug, :string, null: false
add :domain, :string
add :status, :string, default: "active", null: false
add :settings, :map, default: "{}", null: false
timestamps()
end
create unique_index(:<%= @table %>, [:slug])
create unique_index(:<%= @table %>, [:domain])
create index(:<%= @table %>, [:status])
end
end