22
priv/repo/migrations/20171207162439_create_accounts.exs
Normal file
22
priv/repo/migrations/20171207162439_create_accounts.exs
Normal 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
|
||||
16
priv/repo/migrations/20171207162546_create_users.exs
Normal file
16
priv/repo/migrations/20171207162546_create_users.exs
Normal 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
|
||||
17
priv/repo/migrations/20171207162701_create_events.exs
Normal file
17
priv/repo/migrations/20171207162701_create_events.exs
Normal 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
|
||||
14
priv/repo/migrations/20171207162756_create_categories.exs
Normal file
14
priv/repo/migrations/20171207162756_create_categories.exs
Normal 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
|
||||
14
priv/repo/migrations/20171207162857_create_tags.exs
Normal file
14
priv/repo/migrations/20171207162857_create_tags.exs
Normal 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
|
||||
@@ -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
|
||||
@@ -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
|
||||
16
priv/repo/migrations/20171207163640_create_groups.exs
Normal file
16
priv/repo/migrations/20171207163640_create_groups.exs
Normal 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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
17
priv/repo/seeds.exs
Normal file
17
priv/repo/seeds.exs
Normal file
@@ -0,0 +1,17 @@
|
||||
# Script for populating the database. You can run it as:
|
||||
#
|
||||
# mix run priv/repo/seeds.exs
|
||||
#
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# Eventos.Repo.insert!(%Eventos.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
||||
Eventos.Repo.delete_all Eventos.Accounts.User
|
||||
|
||||
Eventos.Accounts.User.changeset(%Eventos.Accounts.User{}, %{username: "Test User", email: "testuser@example.com", password: "secret", password_confirmation: "secret"})
|
||||
|> Eventos.Repo.insert!
|
||||
|
||||
Reference in New Issue
Block a user