From 51c86be13127c0879e66ded7901ce384f502005c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 7 May 2025 19:05:44 +0300 Subject: [PATCH] Add migrations to require Book's Publisher and AuthorRole's Author. --- ...for_author_role_and_publisher_for_book.exs | 29 +++ .../repo/author_role/20250507154242.json | 156 ++++++++++++ .../repo/books/20250507154242.json | 227 ++++++++++++++++++ 3 files changed, 412 insertions(+) create mode 100644 priv/repo/migrations/20250507154238_update_to_require_author_for_author_role_and_publisher_for_book.exs create mode 100644 priv/resource_snapshots/repo/author_role/20250507154242.json create mode 100644 priv/resource_snapshots/repo/books/20250507154242.json diff --git a/priv/repo/migrations/20250507154238_update_to_require_author_for_author_role_and_publisher_for_book.exs b/priv/repo/migrations/20250507154238_update_to_require_author_for_author_role_and_publisher_for_book.exs new file mode 100644 index 0000000..b2de8e5 --- /dev/null +++ b/priv/repo/migrations/20250507154238_update_to_require_author_for_author_role_and_publisher_for_book.exs @@ -0,0 +1,29 @@ +defmodule DecentralisedBookIndex.Repo.Migrations.UpdateToRequireAuthorForAuthorRoleAndPublisherForBook 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(:books) do + modify :publisher_id, :uuid, null: false + end + + alter table(:author_role) do + modify :author_id, :uuid, null: false + end + end + + def down do + alter table(:author_role) do + modify :author_id, :uuid, null: true + end + + alter table(:books) do + modify :publisher_id, :uuid, null: true + end + end +end diff --git a/priv/resource_snapshots/repo/author_role/20250507154242.json b/priv/resource_snapshots/repo/author_role/20250507154242.json new file mode 100644 index 0000000..c4e83f0 --- /dev/null +++ b/priv/resource_snapshots/repo/author_role/20250507154242.json @@ -0,0 +1,156 @@ +{ + "attributes": [ + { + "allow_nil?": false, + "default": "fragment(\"gen_random_uuid()\")", + "generated?": false, + "primary_key?": true, + "references": null, + "size": null, + "source": "id", + "type": "uuid" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "role", + "type": "text" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "order", + "type": "bigint" + }, + { + "allow_nil?": false, + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "inserted_at", + "type": "utc_datetime_usec" + }, + { + "allow_nil?": false, + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "updated_at", + "type": "utc_datetime_usec" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": false, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "author_role_dbi_server_id_fkey", + "on_delete": null, + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "dbi_servers" + }, + "size": null, + "source": "dbi_server_id", + "type": "uuid" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": true, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "author_role_book_id_fkey", + "on_delete": "delete", + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "books" + }, + "size": null, + "source": "book_id", + "type": "uuid" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": false, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "author_role_author_id_fkey", + "on_delete": null, + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "authors" + }, + "size": null, + "source": "author_id", + "type": "uuid" + } + ], + "base_filter": null, + "check_constraints": [], + "custom_indexes": [], + "custom_statements": [], + "has_create_action": true, + "hash": "1D41694BC80A322063433E60AD6EADA7B2D75D3E60AB16AB8DF3B21E07C5751E", + "identities": [], + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "repo": "Elixir.DecentralisedBookIndex.Repo", + "schema": null, + "table": "author_role" +} \ No newline at end of file diff --git a/priv/resource_snapshots/repo/books/20250507154242.json b/priv/resource_snapshots/repo/books/20250507154242.json new file mode 100644 index 0000000..e09be0b --- /dev/null +++ b/priv/resource_snapshots/repo/books/20250507154242.json @@ -0,0 +1,227 @@ +{ + "attributes": [ + { + "allow_nil?": false, + "default": "fragment(\"gen_random_uuid()\")", + "generated?": false, + "primary_key?": true, + "references": null, + "size": null, + "source": "id", + "type": "uuid" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "title", + "type": "text" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "description", + "type": "text" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "published", + "type": "date" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "language", + "type": "text" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "format", + "type": "text" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "page_count", + "type": "bigint" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "cover_image_url", + "type": "text" + }, + { + "allow_nil?": false, + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "inserted_at", + "type": "utc_datetime_usec" + }, + { + "allow_nil?": false, + "default": "fragment(\"(now() AT TIME ZONE 'utc')\")", + "generated?": false, + "primary_key?": false, + "references": null, + "size": null, + "source": "updated_at", + "type": "utc_datetime_usec" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": false, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "books_dbi_server_id_fkey", + "on_delete": null, + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "dbi_servers" + }, + "size": null, + "source": "dbi_server_id", + "type": "uuid" + }, + { + "allow_nil?": true, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": false, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "books_book_editions_registry_id_fkey", + "on_delete": null, + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "book_editions_registries" + }, + "size": null, + "source": "book_editions_registry_id", + "type": "uuid" + }, + { + "allow_nil?": false, + "default": "nil", + "generated?": false, + "primary_key?": false, + "references": { + "deferrable": false, + "destination_attribute": "id", + "destination_attribute_default": null, + "destination_attribute_generated": null, + "index?": false, + "match_type": null, + "match_with": null, + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "name": "books_publisher_id_fkey", + "on_delete": null, + "on_update": null, + "primary_key?": true, + "schema": "public", + "table": "publishers" + }, + "size": null, + "source": "publisher_id", + "type": "uuid" + } + ], + "base_filter": null, + "check_constraints": [], + "custom_indexes": [ + { + "all_tenants?": false, + "concurrently": false, + "error_fields": [], + "fields": [ + { + "type": "string", + "value": "title gin_trgm_ops" + } + ], + "include": null, + "message": null, + "name": "book_title_gin_index", + "nulls_distinct": true, + "prefix": null, + "table": null, + "unique": false, + "using": "GIN", + "where": null + } + ], + "custom_statements": [], + "has_create_action": true, + "hash": "3C57668E6FB029E0B993F1F1D59400D020A690EAA30DC680DB028C8A5F12B24A", + "identities": [], + "multitenancy": { + "attribute": null, + "global": null, + "strategy": null + }, + "repo": "Elixir.DecentralisedBookIndex.Repo", + "schema": null, + "table": "books" +} \ No newline at end of file