Initial commit

This commit is contained in:
2020-12-12 18:38:31 +01:00
commit f877b78f33
117 changed files with 23104 additions and 0 deletions

View File

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

View 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

View 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

View 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

View File

@@ -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

View 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
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:
#
# Confient.Repo.insert!(%Confient.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.