Allow tag relations + bump ecto deps
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
22
priv/repo/migrations/20190208141700_tags_relations.exs
Normal file
22
priv/repo/migrations/20190208141700_tags_relations.exs
Normal file
@@ -0,0 +1,22 @@
|
||||
defmodule Mobilizon.Repo.Migrations.TagsRelations do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
create table(:tag_relations, primary_key: false) do
|
||||
add :tag_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true
|
||||
add :link_id, references(:tags, on_delete: :delete_all), null: false, primary_key: true
|
||||
add :weight, :integer, null: false, default: 1
|
||||
end
|
||||
create constraint(:tag_relations, :no_self_loops_check, check: "tag_id <> link_id")
|
||||
create index(:tag_relations, [:tag_id], name: :index_tag_relations_tag_id)
|
||||
create index(:tag_relations, [:link_id], name: :index_tag_relations_link_id)
|
||||
end
|
||||
|
||||
def down do
|
||||
drop constraint(:tag_relations, :no_self_loops_check)
|
||||
|
||||
drop index(:tag_relations, [:tags_id])
|
||||
drop index(:tag_relations, [:link_id])
|
||||
drop table(:tag_relations)
|
||||
end
|
||||
end
|
||||
48
priv/repo/migrations/20190214100858_drop_datetimetz.exs
Normal file
48
priv/repo/migrations/20190214100858_drop_datetimetz.exs
Normal file
@@ -0,0 +1,48 @@
|
||||
defmodule Mobilizon.Repo.Migrations.DropDatetimetz do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:events) do
|
||||
remove(:begins_on)
|
||||
remove(:ends_on)
|
||||
remove(:publish_at)
|
||||
add(:begins_on, :utc_datetime)
|
||||
add(:ends_on, :utc_datetime)
|
||||
add(:publish_at, :utc_datetime)
|
||||
end
|
||||
|
||||
alter table(:sessions) do
|
||||
remove(:begins_on)
|
||||
remove(:ends_on)
|
||||
add(:begins_on, :utc_datetime)
|
||||
add(:ends_on, :utc_datetime)
|
||||
end
|
||||
|
||||
execute "DROP TYPE datetimetz"
|
||||
end
|
||||
|
||||
def down do
|
||||
execute("""
|
||||
CREATE TYPE datetimetz AS (
|
||||
dt timestamptz,
|
||||
tz varchar
|
||||
);
|
||||
""")
|
||||
|
||||
alter table(:events) do
|
||||
remove(:begins_on)
|
||||
remove(:ends_on)
|
||||
remove(:publish_at)
|
||||
add(:begins_on, :datetimetz)
|
||||
add(:ends_on, :datetimetz)
|
||||
add(:publish_at, :datetimetz)
|
||||
end
|
||||
|
||||
alter table(:sessions) do
|
||||
remove(:begins_on)
|
||||
remove(:ends_on)
|
||||
add(:begins_on, :datetimetz)
|
||||
add(:ends_on, :datetimetz)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,17 +21,21 @@ actor = insert(:actor, user: user)
|
||||
# Insert a second actor account for the same user
|
||||
actor2 = insert(:actor, user: user)
|
||||
|
||||
# Make actor organize a few events
|
||||
event = insert(:event, organizer_actor: actor)
|
||||
event2 = insert(:event, organizer_actor: actor)
|
||||
event3 = insert(:event, organizer_actor: actor)
|
||||
event4 = insert(:event, organizer_actor: actor2)
|
||||
tag1 = insert(:tag)
|
||||
tag2 = insert(:tag)
|
||||
tag3 = insert(:tag)
|
||||
|
||||
participant = insert(:participant, actor: actor, event: event, role: 4)
|
||||
participant = insert(:participant, actor: actor, event: event2, role: 4)
|
||||
participant = insert(:participant, actor: actor, event: event3, role: 4)
|
||||
participant = insert(:participant, actor: actor2, event: event4, role: 4)
|
||||
participant = insert(:participant, actor: actor, event: event4, role: 1)
|
||||
# Make actor organize a few events
|
||||
event = insert(:event, organizer_actor: actor, tags: [tag1, tag2])
|
||||
event2 = insert(:event, organizer_actor: actor, tags: [tag1, tag2])
|
||||
event3 = insert(:event, organizer_actor: actor, tags: [tag1])
|
||||
event4 = insert(:event, organizer_actor: actor2, tags: [tag3, tag2])
|
||||
|
||||
insert(:participant, actor: actor, event: event, role: :creator)
|
||||
insert(:participant, actor: actor, event: event2, role: :creator)
|
||||
insert(:participant, actor: actor, event: event3, role: :creator)
|
||||
insert(:participant, actor: actor2, event: event4, role: :creator)
|
||||
insert(:participant, actor: actor, event: event4, role: :participant)
|
||||
|
||||
# Insert a group
|
||||
group = insert(:actor, type: :Group)
|
||||
|
||||
Reference in New Issue
Block a user