Initial commit
This commit is contained in:
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"]
|
||||
]
|
||||
14
priv/repo/migrations/20201124120633_create_classes.exs
Normal file
14
priv/repo/migrations/20201124120633_create_classes.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule Confient.Repo.Migrations.CreateClasses do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:classes) do
|
||||
add :name, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:classes, [:name])
|
||||
|
||||
end
|
||||
end
|
||||
15
priv/repo/migrations/20201128001745_create_students.exs
Normal file
15
priv/repo/migrations/20201128001745_create_students.exs
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule Confient.Repo.Migrations.CreateStudents do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:students) do
|
||||
add :lastname, :string
|
||||
add :firstname, :string
|
||||
add :class_id, references(:classes, on_delete: :delete_all)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:students, [:lastname, :firstname, :class_id])
|
||||
end
|
||||
end
|
||||
16
priv/repo/migrations/20201128151154_create_assignments.exs
Normal file
16
priv/repo/migrations/20201128151154_create_assignments.exs
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule Confient.Repo.Migrations.CreateAssignments do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:assignments) do
|
||||
add :title, :string
|
||||
add :slug, :string
|
||||
add :due, :date
|
||||
add :class_id, references(:classes, on_delete: :delete_all)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:assignments, [:title, :class_id])
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
defmodule Confient.Repo.Migrations.CreateStudentsWorks do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:students_works) do
|
||||
add :date, :date
|
||||
add :path, :string
|
||||
|
||||
add :student_id, references(:students, on_delete: :delete_all)
|
||||
add :assignment_id, references(:assignments, on_delete: :delete_all)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:students_works, [:student_id, :assignment_id])
|
||||
end
|
||||
end
|
||||
14
priv/repo/migrations/20201205173750_create_users.exs
Normal file
14
priv/repo/migrations/20201205173750_create_users.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule Confient.Repo.Migrations.CreateUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:users) do
|
||||
add :username, :string
|
||||
add :encrypted_password, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:users, [:username])
|
||||
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:
|
||||
#
|
||||
# Confient.Repo.insert!(%Confient.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