Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #296 from renatomassaro/fix-migration
Browse files Browse the repository at this point in the history
Fix FileModule migration
  • Loading branch information
renatomassaro authored Oct 11, 2017
2 parents 6072f70 + 4b83c7f commit 8732ec8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 6 additions & 6 deletions priv/repo/software/migrations/20170401193742_initial_setup.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Helix.Software.Repo.Migrations.InitialSetup do
create unique_index(:files, [:storage_id, :full_path])

create table(:software_modules, primary_key: false) do
add :module, :string, primary_key: true
add :software_module, :string, primary_key: true
add :software_type,
references(:software_types, column: :software_type, type: :string),
null: false
Expand All @@ -54,16 +54,16 @@ defmodule Helix.Software.Repo.Migrations.InitialSetup do
type: :inet,
on_delete: :delete_all),
primary_key: true
add :name,
references(:software_modules, column: :module, type: :string),
add :software_module,
references(:software_modules, column: :software_module, type: :string),
primary_key: true
add :version, :integer, null: false
add :module_version, :integer, null: false
end

create constraint(
:file_modules,
:version_must_be_positive,
check: "version > 0")
:module_version_must_be_positive,
check: "module_version > 0")

# File specializations
create table(:text_files, primary_key: false) do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Helix.Software.Repo.Migrations.ChangeFileModules do
use Ecto.Migration

def change do
rename table(:software_modules), :software_module, to: :module

rename table(:file_modules), :module_version, to: :version
rename table(:file_modules), :software_module, to: :name

drop constraint(:file_modules, :module_version_must_be_positive)
create constraint(
:file_modules,
:version_is_positive,
check: "version > 0"
)
end
end

0 comments on commit 8732ec8

Please sign in to comment.