diff --git a/dev/repo/migrations/20231121063220_add_private_and_sensitive_fields.exs b/dev/repo/migrations/20231121063220_add_private_and_sensitive_fields.exs new file mode 100644 index 0000000..c2e2b26 --- /dev/null +++ b/dev/repo/migrations/20231121063220_add_private_and_sensitive_fields.exs @@ -0,0 +1,23 @@ +defmodule Demo.Repo.Migrations.AddPrivateAndSensitiveFields 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 + add :api_key, :text + add :date_of_birth, :date + end + end + + def down do + alter table(:users) do + remove :date_of_birth + remove :api_key + end + end +end \ No newline at end of file diff --git a/dev/resource_snapshots/repo/users/20231121063220.json b/dev/resource_snapshots/repo/users/20231121063220.json new file mode 100644 index 0000000..b31547a --- /dev/null +++ b/dev/resource_snapshots/repo/users/20231121063220.json @@ -0,0 +1,155 @@ +{ + "attributes": [ + { + "default": "fragment(\"uuid_generate_v4()\")", + "size": null, + "type": "uuid", + "source": "id", + "references": null, + "allow_nil?": false, + "primary_key?": true, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "text", + "source": "first_name", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "text", + "source": "last_name", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "boolean", + "source": "representative", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "false", + "size": null, + "type": "boolean", + "source": "admin", + "references": null, + "allow_nil?": false, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "text", + "source": "api_key", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "date", + "source": "date_of_birth", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": "map", + "source": "profile", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": [ + "array", + "map" + ], + "source": "alternate_profiles", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "nil", + "size": null, + "type": [ + "array", + "text" + ], + "source": "tags", + "references": null, + "allow_nil?": true, + "primary_key?": false, + "generated?": false + }, + { + "default": "fragment(\"now()\")", + "size": null, + "type": "utc_datetime_usec", + "source": "inserted_at", + "references": null, + "allow_nil?": false, + "primary_key?": false, + "generated?": false + }, + { + "default": "fragment(\"now()\")", + "size": null, + "type": "utc_datetime_usec", + "source": "updated_at", + "references": null, + "allow_nil?": false, + "primary_key?": false, + "generated?": false + } + ], + "table": "users", + "hash": "338E5E3B2C34F4001BC0330CAF13D840CBD2B828DFD4CF8FC76FBA53AEFA03D1", + "repo": "Elixir.Demo.Repo", + "schema": null, + "check_constraints": [], + "identities": [ + { + "name": "representative_name", + "keys": [ + "first_name", + "last_name" + ], + "base_filter": "representative = true", + "index_name": "users_representative_name_index" + } + ], + "custom_indexes": [], + "multitenancy": { + "global": null, + "attribute": null, + "strategy": null + }, + "base_filter": null, + "custom_statements": [], + "has_create_action": true +} \ No newline at end of file diff --git a/dev/resources/accounts/resources/user.ex b/dev/resources/accounts/resources/user.ex index 7789041..5dd727e 100644 --- a/dev/resources/accounts/resources/user.ex +++ b/dev/resources/accounts/resources/user.ex @@ -16,7 +16,7 @@ defmodule Demo.Accounts.User do field :last_name, type: :short_text end - table_columns [:id, :first_name, :last_name, :representative, :admin, :full_name] + table_columns [:id, :first_name, :last_name, :representative, :admin, :full_name, :api_key, :date_of_birth] end policies do @@ -94,6 +94,15 @@ defmodule Demo.Accounts.User do default false end + attribute :api_key, :string do + private? true + sensitive? true + end + + attribute :date_of_birth, :date do + sensitive? true + end + attribute :profile, Demo.Accounts.Profile attribute :alternate_profiles, {:array, Demo.Accounts.Profile} attribute :tags, {:array, :string}