initial commit

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2017-12-08 09:58:14 +01:00
commit 90ceb4f6fe
181 changed files with 8219 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
defmodule Eventos.Repo.Migrations.CreateAccounts do
use Ecto.Migration
def change do
create table(:accounts) do
add :username, :string, null: false
add :domain, :string
add :display_name, :string, null: false
add :description, :text
add :private_key, :text
add :public_key, :text, null: false
add :suspended, :boolean, default: false, null: false
add :uri, :string, null: false
add :url, :string
timestamps()
end
create unique_index(:accounts, [:username, :domain])
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateUsers do
use Ecto.Migration
def change do
create table(:users) do
add :username, :string
add :email, :string
add :role, :integer, default: 0
add :account_id, references(:accounts, on_delete: :delete_all, null: false)
timestamps()
end
create unique_index(:users, [:username])
end
end

View File

@@ -0,0 +1,17 @@
defmodule Eventos.Repo.Migrations.CreateEvents do
use Ecto.Migration
def change do
create table(:events) do
add :title, :string, null: false
add :description, :text
add :begin_on, :utc_datetime
add :ends_on, :utc_datetime
add :organizer_id, references(:accounts, on_delete: :nothing), null: false
timestamps()
end
create index(:events, [:organizer_id])
end
end

View File

@@ -0,0 +1,14 @@
defmodule Eventos.Repo.Migrations.CreateCategories do
use Ecto.Migration
def change do
create table(:categories) do
add :title, :string
add :picture, :string
timestamps()
end
create unique_index(:categories, [:title])
end
end

View File

@@ -0,0 +1,14 @@
defmodule Eventos.Repo.Migrations.CreateTags do
use Ecto.Migration
def change do
create table(:tags) do
add :title, :string
add :slug, :string
timestamps()
end
create unique_index(:tags, [:slug])
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateEventAccounts do
use Ecto.Migration
def change do
create table(:event_accounts, primary_key: false) do
add :roles, :integer
add :event_id, references(:events, on_delete: :nothing)
add :account_id, references(:accounts, on_delete: :nothing)
timestamps()
end
create index(:event_accounts, [:event_id])
create index(:event_accounts, [:account_id])
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateEventRequests do
use Ecto.Migration
def change do
create table(:event_requests) do
add :state, :integer
add :event_id, references(:events, on_delete: :nothing)
add :account_id, references(:accounts, on_delete: :nothing)
timestamps()
end
create index(:event_requests, [:event_id])
create index(:event_requests, [:account_id])
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateGroups do
use Ecto.Migration
def change do
create table(:groups) do
add :title, :string
add :description, :string
add :suspended, :boolean, default: false, null: false
add :url, :string
add :uri, :string
timestamps()
end
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateGroupAccounts do
use Ecto.Migration
def change do
create table(:group_accounts, primary_key: false) do
add :role, :integer
add :group_id, references(:groups, on_delete: :nothing)
add :account_id, references(:accounts, on_delete: :nothing)
timestamps()
end
create index(:group_accounts, [:group_id])
create index(:group_accounts, [:account_id])
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateGroupRequest do
use Ecto.Migration
def change do
create table(:group_requests) do
add :state, :integer
add :group_id, references(:groups, on_delete: :nothing)
add :account_id, references(:accounts, on_delete: :nothing)
timestamps()
end
create index(:group_requests, [:group_id])
create index(:group_requests, [:account_id])
end
end

View File

@@ -0,0 +1,32 @@
defmodule Eventos.Repo.Migrations.AddCoherenceToUser do
use Ecto.Migration
def change do
alter table(:users) do
# confirmable
add :confirmation_token, :string
add :confirmed_at, :utc_datetime
add :confirmation_sent_at, :utc_datetime
# rememberable
add :remember_created_at, :utc_datetime
# authenticatable
add :password_hash, :string
add :active, :boolean, null: false, default: true
# recoverable
add :reset_password_token, :string
add :reset_password_sent_at, :utc_datetime
# lockable
add :failed_attempts, :integer, default: 0
add :locked_at, :utc_datetime
# trackable
add :sign_in_count, :integer, default: 0
add :current_sign_in_at, :utc_datetime
add :last_sign_in_at, :utc_datetime
add :current_sign_in_ip, :string
add :last_sign_in_ip, :string
# unlockable_with_token
add :unlock_token, :string
end
end
end

View File

@@ -0,0 +1,15 @@
defmodule Eventos.Repo.Migrations.CreateCoherenceInvitable do
use Ecto.Migration
def change do
create table(:invitations) do
add :name, :string
add :email, :string
add :token, :string
timestamps()
end
create unique_index(:invitations, [:email])
create index(:invitations, [:token])
end
end

View File

@@ -0,0 +1,19 @@
defmodule Eventos.Repo.Migrations.CreateCoherenceRememberable do
use Ecto.Migration
def change do
create table(:rememberables) do
add :series_hash, :string
add :token_hash, :string
add :token_created_at, :utc_datetime
add :user_id, references(:users, on_delete: :delete_all)
timestamps()
end
create index(:rememberables, [:user_id])
create index(:rememberables, [:series_hash])
create index(:rememberables, [:token_hash])
create unique_index(:rememberables, [:user_id, :series_hash, :token_hash])
end
end