-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Generate migration that Ash wanted to generate
yThe last one was generated three years ago, so despite nothing changing, Ash thinks things should change!
- Loading branch information
1 parent
aaf1f13
commit 2762e2c
Showing
6 changed files
with
951 additions
and
0 deletions.
There are no files selected for viewing
334 changes: 334 additions & 0 deletions
334
dev/repo/migrations/20231121062843_add_missing_fields.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,334 @@ | ||
defmodule Demo.Repo.Migrations.AddMissingFields do | ||
@moduledoc """ | ||
Updates resources based on their most recent snapshots. | ||
This file was autogenerated with `mix ash_postgres.generate_migrations` | ||
""" | ||
|
||
use Ecto.Migration | ||
|
||
def up do | ||
alter table(:users) do | ||
modify :updated_at, :utc_datetime_usec, null: false | ||
modify :inserted_at, :utc_datetime_usec, null: false | ||
modify :admin, :boolean, null: false | ||
modify :representative, :boolean | ||
modify :last_name, :text | ||
modify :first_name, :text | ||
modify :id, :uuid | ||
end | ||
|
||
execute( | ||
"ALTER INDEX users_representative_name_unique_index RENAME TO users_representative_name_index" | ||
) | ||
|
||
drop constraint(:tickets, "tickets_organization_id_fkey") | ||
|
||
drop constraint(:tickets, "tickets_representative_id_fkey") | ||
|
||
drop constraint(:tickets, "tickets_reporter_id_fkey") | ||
|
||
alter table(:tickets) do | ||
modify :status, :text, default: "new" | ||
|
||
modify :reporter_id, | ||
references(:users, | ||
column: :id, | ||
name: "tickets_reporter_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
drop constraint(:ticket_links, "ticket_links_destination_id_fkey") | ||
|
||
drop constraint(:ticket_links, "ticket_links_source_id_fkey") | ||
|
||
alter table(:ticket_links) do | ||
modify :source_id, | ||
references(:tickets, | ||
column: :id, | ||
name: "ticket_links_source_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_commenting_representative_id_fkey") | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_commenting_customer_id_fkey") | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_resource_id_fkey") | ||
|
||
alter table(:ticket_comments) do | ||
modify :resource_id, | ||
references(:tickets, | ||
column: :id, | ||
name: "ticket_comments_resource_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint( | ||
:representative_comments, | ||
"representative_comments_commenting_representative_id_fkey" | ||
) | ||
|
||
drop constraint( | ||
:representative_comments, | ||
"representative_comments_commenting_customer_id_fkey" | ||
) | ||
|
||
drop constraint(:representative_comments, "representative_comments_resource_id_fkey") | ||
|
||
alter table(:representative_comments) do | ||
modify :resource_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_resource_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_resource_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
alter table(:representative_comments) do | ||
modify :commenting_customer_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_commenting_customer_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_commenting_customer_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
alter table(:representative_comments) do | ||
modify :commenting_representative_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_commenting_representative_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_commenting_representative_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
execute( | ||
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_resource_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
alter table(:ticket_comments) do | ||
modify :commenting_customer_id, | ||
references(:users, | ||
column: :id, | ||
name: "ticket_comments_commenting_customer_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_commenting_customer_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
alter table(:ticket_comments) do | ||
modify :commenting_representative_id, | ||
references(:users, | ||
column: :id, | ||
name: "ticket_comments_commenting_representative_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_commenting_representative_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
execute( | ||
"ALTER TABLE ticket_links alter CONSTRAINT ticket_links_source_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
alter table(:ticket_links) do | ||
modify :destination_id, | ||
references(:tickets, | ||
column: :id, | ||
name: "ticket_links_destination_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute( | ||
"ALTER TABLE ticket_links alter CONSTRAINT ticket_links_destination_id_fkey NOT DEFERRABLE" | ||
) | ||
|
||
execute("ALTER TABLE tickets alter CONSTRAINT tickets_reporter_id_fkey NOT DEFERRABLE") | ||
|
||
alter table(:tickets) do | ||
modify :representative_id, | ||
references(:users, | ||
column: :id, | ||
name: "tickets_representative_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute("ALTER TABLE tickets alter CONSTRAINT tickets_representative_id_fkey NOT DEFERRABLE") | ||
|
||
alter table(:tickets) do | ||
modify :organization_id, | ||
references(:organizations, | ||
column: :id, | ||
name: "tickets_organization_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
end | ||
|
||
execute("ALTER TABLE tickets alter CONSTRAINT tickets_organization_id_fkey NOT DEFERRABLE") | ||
end | ||
|
||
def down do | ||
drop constraint(:tickets, "tickets_organization_id_fkey") | ||
|
||
alter table(:tickets) do | ||
modify :organization_id, | ||
references(:organizations, | ||
column: :id, | ||
name: "tickets_organization_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:tickets, "tickets_representative_id_fkey") | ||
|
||
alter table(:tickets) do | ||
modify :representative_id, | ||
references(:users, column: :id, name: "tickets_representative_id_fkey", type: :uuid) | ||
end | ||
|
||
drop constraint(:ticket_links, "ticket_links_destination_id_fkey") | ||
|
||
alter table(:ticket_links) do | ||
modify :destination_id, | ||
references(:tickets, | ||
column: :id, | ||
name: "ticket_links_destination_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_commenting_representative_id_fkey") | ||
|
||
alter table(:ticket_comments) do | ||
modify :commenting_representative_id, | ||
references(:users, | ||
column: :id, | ||
name: "ticket_comments_commenting_representative_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_commenting_customer_id_fkey") | ||
|
||
alter table(:ticket_comments) do | ||
modify :commenting_customer_id, | ||
references(:users, | ||
column: :id, | ||
name: "ticket_comments_commenting_customer_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint( | ||
:representative_comments, | ||
"representative_comments_commenting_representative_id_fkey" | ||
) | ||
|
||
alter table(:representative_comments) do | ||
modify :commenting_representative_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_commenting_representative_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint( | ||
:representative_comments, | ||
"representative_comments_commenting_customer_id_fkey" | ||
) | ||
|
||
alter table(:representative_comments) do | ||
modify :commenting_customer_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_commenting_customer_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:representative_comments, "representative_comments_resource_id_fkey") | ||
|
||
alter table(:representative_comments) do | ||
modify :resource_id, | ||
references(:users, | ||
column: :id, | ||
name: "representative_comments_resource_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:ticket_comments, "ticket_comments_resource_id_fkey") | ||
|
||
alter table(:ticket_comments) do | ||
modify :resource_id, | ||
references(:tickets, | ||
column: :id, | ||
name: "ticket_comments_resource_id_fkey", | ||
type: :uuid | ||
) | ||
end | ||
|
||
drop constraint(:ticket_links, "ticket_links_source_id_fkey") | ||
|
||
alter table(:ticket_links) do | ||
modify :source_id, | ||
references(:tickets, column: :id, name: "ticket_links_source_id_fkey", type: :uuid) | ||
end | ||
|
||
drop constraint(:tickets, "tickets_reporter_id_fkey") | ||
|
||
alter table(:tickets) do | ||
modify :reporter_id, | ||
references(:users, column: :id, name: "tickets_reporter_id_fkey", type: :uuid) | ||
|
||
modify :status, :text, default: nil | ||
end | ||
|
||
execute( | ||
"ALTER INDEX users_representative_name_index RENAME TO users_representative_name_unique_index" | ||
) | ||
|
||
alter table(:users) do | ||
modify :id, :uuid | ||
modify :first_name, :text | ||
modify :last_name, :text | ||
modify :representative, :boolean | ||
modify :admin, :boolean, null: true | ||
modify :inserted_at, :utc_datetime_usec, null: true | ||
modify :updated_at, :utc_datetime_usec, null: true | ||
end | ||
end | ||
end |
Oops, something went wrong.