Change models, new migrations, fix front and make tests work

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-01-13 23:33:03 +01:00
parent 92d2045735
commit 20cd1bb579
186 changed files with 2982 additions and 3214 deletions

View File

@@ -1,17 +0,0 @@
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

@@ -1,16 +0,0 @@
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.Prerequites do
use Ecto.Migration
def up do
execute """
CREATE TYPE datetimetz AS (
dt timestamptz,
tz varchar
);
"""
end
def down do
execute "DROP TYPE IF EXISTS datetimetz;"
end
end

View File

@@ -4,14 +4,14 @@ defmodule Eventos.Repo.Migrations.CreateAccounts do
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 :domain, :string, null: true
add :display_name, :string, null: true
add :description, :text, null: true
add :private_key, :text, null: true
add :public_key, :text, null: false
add :suspended, :boolean, default: false, null: false
add :uri, :string
add :url, :string
add :uri, :string, null: false
add :url, :string, null: false
timestamps()
end

View File

@@ -0,0 +1,26 @@
defmodule Eventos.Repo.Migrations.CreateEvents do
use Ecto.Migration
def change do
create table(:events) do
add :title, :string, null: false
add :slug, :string, null: false
add :description, :string, null: true
add :begins_on, :datetimetz
add :ends_on, :datetimetz
add :geom, :geometry
add :state, :integer, null: false
add :public, :boolean, null: false
add :large_image, :string
add :thumbnail, :string
add :publish_at, :datetimetz
add :organizer_id, references(:accounts, on_delete: :nothing), null: false
timestamps()
end
create index(:events, [:organizer_id])
create unique_index(:events, [:slug])
end
end

View File

@@ -4,11 +4,13 @@ defmodule Eventos.Repo.Migrations.CreateCategories do
def change do
create table(:categories) do
add :title, :string
add :description, :string
add :picture, :string
timestamps()
end
create unique_index(:categories, [:title])
end
end

View File

@@ -4,11 +4,12 @@ defmodule Eventos.Repo.Migrations.CreateTags do
def change do
create table(:tags) do
add :title, :string
add :slug, :string
add :slug, :string, null: false
timestamps()
end
create unique_index(:tags, [:slug])
end
end

View File

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

View File

@@ -12,5 +12,6 @@ defmodule Eventos.Repo.Migrations.CreateEventRequests do
create index(:event_requests, [:event_id])
create index(:event_requests, [:account_id])
end
end

View File

@@ -3,7 +3,8 @@ defmodule Eventos.Repo.Migrations.CreateGroups do
def change do
create table(:groups) do
add :title, :string
add :title, :string, null: false
add :slug, :string, null: false
add :description, :string
add :suspended, :boolean, default: false, null: false
add :url, :string
@@ -12,5 +13,7 @@ defmodule Eventos.Repo.Migrations.CreateGroups do
timestamps()
end
create unique_index(:groups, [:slug])
end
end

View File

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

View File

@@ -1,4 +1,4 @@
defmodule Eventos.Repo.Migrations.CreateGroupRequest do
defmodule Eventos.Repo.Migrations.CreateGroupRequests do
use Ecto.Migration
def change do
@@ -12,5 +12,6 @@ defmodule Eventos.Repo.Migrations.CreateGroupRequest do
create index(:group_requests, [:group_id])
create index(:group_requests, [:account_id])
end
end

View File

@@ -0,0 +1,17 @@
defmodule Eventos.Repo.Migrations.Guardian.DB do
use Ecto.Migration
def change do
create table(:guardian_tokens, primary_key: false) do
add(:jti, :string, primary_key: true)
add(:aud, :string, primary_key: true)
add(:typ, :string)
add(:iss, :string)
add(:sub, :string)
add(:exp, :bigint)
add(:jwt, :text)
add(:claims, :map)
timestamps()
end
end
end

View File

@@ -0,0 +1,16 @@
defmodule Eventos.Repo.Migrations.CreateTracks do
use Ecto.Migration
def change do
create table(:tracks) do
add :name, :string
add :description, :text
add :color, :string
add :event_id, references(:events, on_delete: :delete_all), null: false
timestamps()
end
end
end

View File

@@ -0,0 +1,24 @@
defmodule Eventos.Repo.Migrations.CreateSessions do
use Ecto.Migration
def change do
create table(:sessions) do
add :title, :string
add :subtitle, :string
add :short_abstract, :text
add :long_abstract, :text
add :language, :string
add :slides_url, :string
add :videos_urls, :string
add :audios_urls, :string
add :begins_on, :datetimetz
add :ends_on, :datetimetz
add :event_id, references(:events, on_delete: :delete_all), null: false
add :track_id, references(:tracks, on_delete: :delete_all)
add :speaker_id, references(:accounts, on_delete: :delete_all)
timestamps()
end
end
end