Skip to content

Commit

Permalink
chore: Add some sensitive fields to the demo app for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenseacat committed Nov 21, 2023
1 parent 2762e2c commit 652611d
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
155 changes: 155 additions & 0 deletions dev/resource_snapshots/repo/users/20231121063220.json
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 10 additions & 1 deletion dev/resources/accounts/resources/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 652611d

Please sign in to comment.