Update DBIServer to add a relationship to itself and the sync on attribute.

dev
KKlochko 2 months ago
parent 0415938248
commit 2d78c2bd1b

@ -21,12 +21,12 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
create :create do
primary? true
accept [:name, :url]
accept [:name, :url, :sync_on?]
end
update :update do
primary? true
accept [:name, :url]
accept [:name, :url, :sync_on?]
end
read :by_id do
@ -51,6 +51,10 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
bypass actor_attribute_equals(:role, :admin) do
authorize_if always()
end
policy action_type(:read) do
authorize_if always()
end
end
attributes do
@ -66,6 +70,11 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
public? true
end
attribute :sync_on?, :boolean do
allow_nil? true
default false
end
timestamps do
writable? true
public? true
@ -73,6 +82,8 @@ defmodule DecentralisedBookIndex.Metadata.DBIServer do
end
relationships do
belongs_to :dbi_server, Metadata.DBIServer
has_many :author, Metadata.Author
has_many :author_alias_registries, Metadata.AuthorAliasRegistry
has_many :author_roles, Metadata.AuthorRole

@ -0,0 +1,32 @@
defmodule DecentralisedBookIndex.Repo.Migrations.UpdateDbiServerToAddRelationshipToItselfAndSyncOnAttribute 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(:dbi_servers) do
add :sync_on?, :boolean, default: false
add :dbi_server_id,
references(:dbi_servers,
column: :id,
name: "dbi_servers_dbi_server_id_fkey",
type: :uuid,
prefix: "public"
)
end
end
def down do
drop constraint(:dbi_servers, "dbi_servers_dbi_server_id_fkey")
alter table(:dbi_servers) do
remove :dbi_server_id
remove :sync_on?
end
end
end

@ -0,0 +1,129 @@
{
"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": "name",
"type": "text"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "url",
"type": "text"
},
{
"allow_nil?": true,
"default": "false",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "sync_on?",
"type": "boolean"
},
{
"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": "dbi_servers_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"
}
],
"base_filter": null,
"check_constraints": [],
"custom_indexes": [
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [],
"fields": [
{
"type": "string",
"value": "name gin_trgm_ops"
}
],
"include": null,
"message": null,
"name": "server_name_gin_index",
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": "GIN",
"where": null
}
],
"custom_statements": [],
"has_create_action": true,
"hash": "9EDA6BBD6005F48CE5FAFDEE80AEF0C1B3A98440F9287B4294CF64D5BB02F199",
"identities": [],
"multitenancy": {
"attribute": null,
"global": null,
"strategy": null
},
"repo": "Elixir.DecentralisedBookIndex.Repo",
"schema": null,
"table": "dbi_servers"
}
Loading…
Cancel
Save