Skip to content

Commit

Permalink
Allow nil usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed Mar 27, 2024
1 parent db5e73b commit b9d99e9
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/lib/orcasite/accounts/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Orcasite.Accounts.User do
attribute :moderator, :boolean, default: false, allow_nil?: false

attribute :username, :string do
allow_nil? false
allow_nil? true
constraints allow_empty?: false, trim?: true
end

Expand Down
21 changes: 21 additions & 0 deletions server/priv/repo/migrations/20240327003711_allow_username_nil.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defmodule Orcasite.Repo.Migrations.AllowUsernameNil 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 :username, :text, null: true
end
end

def down do
alter table(:users) do
modify :username, :text, null: false
end
end
end
138 changes: 138 additions & 0 deletions server/priv/resource_snapshots/repo/users/20240327003711.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"attributes": [
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"allow_nil?": false,
"primary_key?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "citext",
"source": "email",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "hashed_password",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"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": "false",
"size": null,
"type": "boolean",
"source": "admin",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "false",
"size": null,
"type": "boolean",
"source": "moderator",
"references": null,
"allow_nil?": false,
"primary_key?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "username",
"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": "91403CD4D2917E7800C44400B4C877BF297E35698C43621B11C9011D076A98CE",
"repo": "Elixir.Orcasite.Repo",
"identities": [
{
"name": "unique_email",
"keys": [
"email"
],
"base_filter": null,
"all_tenants?": false,
"index_name": "users_unique_email_index"
},
{
"name": "unique_username",
"keys": [
"username"
],
"base_filter": null,
"all_tenants?": false,
"index_name": "users_unique_username_index"
}
],
"schema": null,
"check_constraints": [],
"custom_indexes": [],
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"base_filter": null,
"custom_statements": [],
"has_create_action": true
}

0 comments on commit b9d99e9

Please sign in to comment.