Skip to content

Commit

Permalink
improvement: support for unions
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed May 17, 2024
1 parent 809f041 commit 284c97b
Show file tree
Hide file tree
Showing 17 changed files with 959 additions and 207 deletions.
47 changes: 47 additions & 0 deletions dev/repo/migrations/20240516215427_migrate_resources6.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
defmodule Demo.Repo.Migrations.MigrateResources6 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
drop_if_exists(
unique_index(:users, [:id, :first_name, :last_name],
name: "users_representative_name_index"
)
)

create(
unique_index(:users, [:org, :first_name, :last_name],
where: "representative = true",
name: "users_representative_name_index"
)
)

alter table(:tickets) do
add(:metadata, :map)
end
end

def down do
alter table(:tickets) do
remove(:metadata)
end

drop_if_exists(
unique_index(:users, [:org, :first_name, :last_name],
name: "users_representative_name_index"
)
)

create(
unique_index(:users, [:org, :first_name, :last_name],
where: "representative = true",
name: "users_representative_name_index"
)
)
end
end
183 changes: 183 additions & 0 deletions dev/resource_snapshots/repo/tickets/20240516215427.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"allow_nil?": false,
"primary_key?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "subject",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "map",
"source": "metadata",
"references": null,
"allow_nil?": true,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "description",
"references": null,
"allow_nil?": true,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "response",
"references": null,
"allow_nil?": true,
"primary_key?": false,
"generated?": false
},
{
"default": "\"new\"",
"size": null,
"type": "text",
"source": "status",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "reporter_id",
"references": {
"name": "tickets_reporter_id_fkey",
"table": "users",
"destination_attribute": "id",
"primary_key?": true,
"schema": "public",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"on_delete": null,
"on_update": null,
"deferrable": false,
"match_with": null,
"match_type": null,
"destination_attribute_default": null,
"destination_attribute_generated": null
},
"allow_nil?": true,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "representative_id",
"references": {
"name": "tickets_representative_id_fkey",
"table": "users",
"destination_attribute": "id",
"primary_key?": true,
"schema": "public",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"on_delete": null,
"on_update": null,
"deferrable": false,
"match_with": null,
"match_type": null,
"destination_attribute_default": null,
"destination_attribute_generated": null
},
"allow_nil?": true,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "organization_id",
"references": {
"name": "tickets_organization_id_fkey",
"table": "organizations",
"destination_attribute": "id",
"primary_key?": true,
"schema": "public",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"on_delete": null,
"on_update": null,
"deferrable": false,
"match_with": null,
"match_type": null,
"destination_attribute_default": null,
"destination_attribute_generated": null
},
"allow_nil?": false,
"primary_key?": false,
"generated?": false
}
],
"table": "tickets",
"hash": "24D2DA4ADA475CF4B05D30CF592EAB2C5978B4DBFE4A65CCE0F9CCB793526262",
"repo": "Elixir.Demo.Repo",
"schema": null,
"check_constraints": [],
"identities": [],
"custom_indexes": [],
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"base_filter": null,
"custom_statements": [],
"has_create_action": true
}
Loading

0 comments on commit 284c97b

Please sign in to comment.