2021-10-29 16:12:23 +00:00
|
|
|
defmodule LiveBeats.Repo.Migrations.CreateSongs do
|
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def change do
|
|
|
|
create table(:songs) do
|
|
|
|
add :album_artist, :string
|
2021-11-05 19:57:33 +00:00
|
|
|
add :artist, :string, null: false
|
|
|
|
add :duration, :integer, default: 0, null: false
|
|
|
|
add :status, :integer, null: false, default: 1
|
|
|
|
add :played_at, :utc_datetime
|
|
|
|
add :paused_at, :utc_datetime
|
|
|
|
add :title, :string, null: false
|
2021-11-06 03:02:31 +00:00
|
|
|
add :mp3_url, :string, null: false
|
|
|
|
add :mp3_filename, :string, null: false
|
2021-11-05 19:57:33 +00:00
|
|
|
add :mp3_filepath, :string, null: false
|
2021-10-29 16:12:23 +00:00
|
|
|
add :date_recorded, :naive_datetime
|
|
|
|
add :date_released, :naive_datetime
|
|
|
|
add :user_id, references(:users, on_delete: :nothing)
|
|
|
|
add :genre_id, references(:genres, on_delete: :nothing)
|
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
create unique_index(:songs, [:user_id, :title, :artist])
|
|
|
|
create index(:songs, [:user_id])
|
|
|
|
create index(:songs, [:genre_id])
|
2021-11-05 19:57:33 +00:00
|
|
|
create index(:songs, [:status])
|
2021-10-29 16:12:23 +00:00
|
|
|
end
|
|
|
|
end
|