Skip to content

Commit

Permalink
feat: Hide sensitive attributes by default (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenseacat authored Nov 21, 2023
1 parent aaf1f13 commit 7db3b48
Show file tree
Hide file tree
Showing 16 changed files with 1,225 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Then, you can start the app with: `mix dev`

If you make changes to the resources, you can generate migrations with `mix generate_migrations`

If you make changes to any of the assets (CSS or JavaScript), including updating dependencies that include assets such as LiveView, you will need to recompile the assets with `mix assets.build`.
If you make changes to any of the assets (CSS or JavaScript), including updating dependencies that include assets such as LiveView, you will need to recompile the assets with `mix assets.deploy`.

## Contributors

Expand Down
334 changes: 334 additions & 0 deletions dev/repo/migrations/20231121062843_add_missing_fields.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,334 @@
defmodule Demo.Repo.Migrations.AddMissingFields 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
modify :updated_at, :utc_datetime_usec, null: false
modify :inserted_at, :utc_datetime_usec, null: false
modify :admin, :boolean, null: false
modify :representative, :boolean
modify :last_name, :text
modify :first_name, :text
modify :id, :uuid
end

execute(
"ALTER INDEX users_representative_name_unique_index RENAME TO users_representative_name_index"
)

drop constraint(:tickets, "tickets_organization_id_fkey")

drop constraint(:tickets, "tickets_representative_id_fkey")

drop constraint(:tickets, "tickets_reporter_id_fkey")

alter table(:tickets) do
modify :status, :text, default: "new"

modify :reporter_id,
references(:users,
column: :id,
name: "tickets_reporter_id_fkey",
type: :uuid,
prefix: "public"
)
end

drop constraint(:ticket_links, "ticket_links_destination_id_fkey")

drop constraint(:ticket_links, "ticket_links_source_id_fkey")

alter table(:ticket_links) do
modify :source_id,
references(:tickets,
column: :id,
name: "ticket_links_source_id_fkey",
type: :uuid,
prefix: "public"
)
end

drop constraint(:ticket_comments, "ticket_comments_commenting_representative_id_fkey")

drop constraint(:ticket_comments, "ticket_comments_commenting_customer_id_fkey")

drop constraint(:ticket_comments, "ticket_comments_resource_id_fkey")

alter table(:ticket_comments) do
modify :resource_id,
references(:tickets,
column: :id,
name: "ticket_comments_resource_id_fkey",
type: :uuid
)
end

drop constraint(
:representative_comments,
"representative_comments_commenting_representative_id_fkey"
)

drop constraint(
:representative_comments,
"representative_comments_commenting_customer_id_fkey"
)

drop constraint(:representative_comments, "representative_comments_resource_id_fkey")

alter table(:representative_comments) do
modify :resource_id,
references(:users,
column: :id,
name: "representative_comments_resource_id_fkey",
type: :uuid
)
end

execute(
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_resource_id_fkey NOT DEFERRABLE"
)

alter table(:representative_comments) do
modify :commenting_customer_id,
references(:users,
column: :id,
name: "representative_comments_commenting_customer_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute(
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_commenting_customer_id_fkey NOT DEFERRABLE"
)

alter table(:representative_comments) do
modify :commenting_representative_id,
references(:users,
column: :id,
name: "representative_comments_commenting_representative_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute(
"ALTER TABLE representative_comments alter CONSTRAINT representative_comments_commenting_representative_id_fkey NOT DEFERRABLE"
)

execute(
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_resource_id_fkey NOT DEFERRABLE"
)

alter table(:ticket_comments) do
modify :commenting_customer_id,
references(:users,
column: :id,
name: "ticket_comments_commenting_customer_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute(
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_commenting_customer_id_fkey NOT DEFERRABLE"
)

alter table(:ticket_comments) do
modify :commenting_representative_id,
references(:users,
column: :id,
name: "ticket_comments_commenting_representative_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute(
"ALTER TABLE ticket_comments alter CONSTRAINT ticket_comments_commenting_representative_id_fkey NOT DEFERRABLE"
)

execute(
"ALTER TABLE ticket_links alter CONSTRAINT ticket_links_source_id_fkey NOT DEFERRABLE"
)

alter table(:ticket_links) do
modify :destination_id,
references(:tickets,
column: :id,
name: "ticket_links_destination_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute(
"ALTER TABLE ticket_links alter CONSTRAINT ticket_links_destination_id_fkey NOT DEFERRABLE"
)

execute("ALTER TABLE tickets alter CONSTRAINT tickets_reporter_id_fkey NOT DEFERRABLE")

alter table(:tickets) do
modify :representative_id,
references(:users,
column: :id,
name: "tickets_representative_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute("ALTER TABLE tickets alter CONSTRAINT tickets_representative_id_fkey NOT DEFERRABLE")

alter table(:tickets) do
modify :organization_id,
references(:organizations,
column: :id,
name: "tickets_organization_id_fkey",
type: :uuid,
prefix: "public"
)
end

execute("ALTER TABLE tickets alter CONSTRAINT tickets_organization_id_fkey NOT DEFERRABLE")
end

def down do
drop constraint(:tickets, "tickets_organization_id_fkey")

alter table(:tickets) do
modify :organization_id,
references(:organizations,
column: :id,
name: "tickets_organization_id_fkey",
type: :uuid
)
end

drop constraint(:tickets, "tickets_representative_id_fkey")

alter table(:tickets) do
modify :representative_id,
references(:users, column: :id, name: "tickets_representative_id_fkey", type: :uuid)
end

drop constraint(:ticket_links, "ticket_links_destination_id_fkey")

alter table(:ticket_links) do
modify :destination_id,
references(:tickets,
column: :id,
name: "ticket_links_destination_id_fkey",
type: :uuid
)
end

drop constraint(:ticket_comments, "ticket_comments_commenting_representative_id_fkey")

alter table(:ticket_comments) do
modify :commenting_representative_id,
references(:users,
column: :id,
name: "ticket_comments_commenting_representative_id_fkey",
type: :uuid
)
end

drop constraint(:ticket_comments, "ticket_comments_commenting_customer_id_fkey")

alter table(:ticket_comments) do
modify :commenting_customer_id,
references(:users,
column: :id,
name: "ticket_comments_commenting_customer_id_fkey",
type: :uuid
)
end

drop constraint(
:representative_comments,
"representative_comments_commenting_representative_id_fkey"
)

alter table(:representative_comments) do
modify :commenting_representative_id,
references(:users,
column: :id,
name: "representative_comments_commenting_representative_id_fkey",
type: :uuid
)
end

drop constraint(
:representative_comments,
"representative_comments_commenting_customer_id_fkey"
)

alter table(:representative_comments) do
modify :commenting_customer_id,
references(:users,
column: :id,
name: "representative_comments_commenting_customer_id_fkey",
type: :uuid
)
end

drop constraint(:representative_comments, "representative_comments_resource_id_fkey")

alter table(:representative_comments) do
modify :resource_id,
references(:users,
column: :id,
name: "representative_comments_resource_id_fkey",
type: :uuid
)
end

drop constraint(:ticket_comments, "ticket_comments_resource_id_fkey")

alter table(:ticket_comments) do
modify :resource_id,
references(:tickets,
column: :id,
name: "ticket_comments_resource_id_fkey",
type: :uuid
)
end

drop constraint(:ticket_links, "ticket_links_source_id_fkey")

alter table(:ticket_links) do
modify :source_id,
references(:tickets, column: :id, name: "ticket_links_source_id_fkey", type: :uuid)
end

drop constraint(:tickets, "tickets_reporter_id_fkey")

alter table(:tickets) do
modify :reporter_id,
references(:users, column: :id, name: "tickets_reporter_id_fkey", type: :uuid)

modify :status, :text, default: nil
end

execute(
"ALTER INDEX users_representative_name_index RENAME TO users_representative_name_unique_index"
)

alter table(:users) do
modify :id, :uuid
modify :first_name, :text
modify :last_name, :text
modify :representative, :boolean
modify :admin, :boolean, null: true
modify :inserted_at, :utc_datetime_usec, null: true
modify :updated_at, :utc_datetime_usec, null: true
end
end
end
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
Loading

0 comments on commit 7db3b48

Please sign in to comment.