4
priv/repo/migrations/.formatter.exs
Normal file
4
priv/repo/migrations/.formatter.exs
Normal file
@@ -0,0 +1,4 @@
|
||||
[
|
||||
import_deps: [:ecto_sql],
|
||||
inputs: ["*.exs"]
|
||||
]
|
||||
12
priv/repo/migrations/20191004231022_create_rooms.exs
Normal file
12
priv/repo/migrations/20191004231022_create_rooms.exs
Normal file
@@ -0,0 +1,12 @@
|
||||
defmodule Anonbb.Repo.Migrations.CreateRooms do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:rooms) do
|
||||
add :name, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
7
priv/repo/migrations/20191005220011_unique_room_name.exs
Normal file
7
priv/repo/migrations/20191005220011_unique_room_name.exs
Normal file
@@ -0,0 +1,7 @@
|
||||
defmodule Anonbb.Repo.Migrations.UniqueRoomName do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create index(:rooms, ["lower(name)"], name: :rooms_name_index, unique: true)
|
||||
end
|
||||
end
|
||||
14
priv/repo/migrations/20191006001359_create_messages.exs
Normal file
14
priv/repo/migrations/20191006001359_create_messages.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule Anonbb.Repo.Migrations.CreateMessages do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:messages) do
|
||||
add :text, :string
|
||||
add :room_id, references(:rooms, on_delete: :nothing)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:messages, [:room_id])
|
||||
end
|
||||
end
|
||||
11
priv/repo/seeds.exs
Normal file
11
priv/repo/seeds.exs
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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:
|
||||
#
|
||||
# Anonbb.Repo.insert!(%Anonbb.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
Reference in New Issue
Block a user