Initial commit

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2019-10-09 08:59:53 -04:00
commit fe85447557
62 changed files with 7907 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
[
import_deps: [:ecto_sql],
inputs: ["*.exs"]
]

View 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

View 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

View 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
View 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.