-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set admin and moderator to non-null and false by default
- Loading branch information
Showing
4 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
server/priv/repo/migrations/20240110222226_update_user_admin_and_mod_default_false.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule Orcasite.Repo.Migrations.UpdateUserAdminAndModDefaultFalse 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 | ||
execute "update users set admin = 'f' where admin is null;" | ||
execute "update users set moderator = 'f' where moderator is null;" | ||
|
||
flush() | ||
|
||
alter table(:users) do | ||
modify :moderator, :boolean, null: false, default: false | ||
modify :admin, :boolean, null: false, default: false | ||
end | ||
end | ||
|
||
def down do | ||
alter table(:users) do | ||
modify :admin, :boolean, null: true, default: nil | ||
modify :moderator, :boolean, null: true, default: nil | ||
end | ||
end | ||
end |
118 changes: 118 additions & 0 deletions
118
server/priv/resource_snapshots/repo/users/20240110222226.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ | ||
"attributes": [ | ||
{ | ||
"default": "nil", | ||
"size": null, | ||
"type": "uuid", | ||
"source": "id", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": true | ||
}, | ||
{ | ||
"default": "nil", | ||
"size": null, | ||
"type": "citext", | ||
"source": "email", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "nil", | ||
"size": null, | ||
"type": "text", | ||
"source": "hashed_password", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "nil", | ||
"size": null, | ||
"type": "text", | ||
"source": "first_name", | ||
"references": null, | ||
"allow_nil?": true, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "nil", | ||
"size": null, | ||
"type": "text", | ||
"source": "last_name", | ||
"references": null, | ||
"allow_nil?": true, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "false", | ||
"size": null, | ||
"type": "boolean", | ||
"source": "admin", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "false", | ||
"size": null, | ||
"type": "boolean", | ||
"source": "moderator", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "fragment(\"now()\")", | ||
"size": null, | ||
"type": "utc_datetime_usec", | ||
"source": "inserted_at", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
}, | ||
{ | ||
"default": "fragment(\"now()\")", | ||
"size": null, | ||
"type": "utc_datetime_usec", | ||
"source": "updated_at", | ||
"references": null, | ||
"allow_nil?": false, | ||
"generated?": false, | ||
"primary_key?": false | ||
} | ||
], | ||
"table": "users", | ||
"hash": "B341A513EC6CF961202B8212C7C4E69600B5AE7A5669D8960EF59C9B41C16164", | ||
"repo": "Elixir.Orcasite.Repo", | ||
"identities": [ | ||
{ | ||
"name": "unique_email", | ||
"keys": [ | ||
"email" | ||
], | ||
"index_name": "users_unique_email_index", | ||
"base_filter": null | ||
} | ||
], | ||
"schema": null, | ||
"multitenancy": { | ||
"global": null, | ||
"strategy": null, | ||
"attribute": null | ||
}, | ||
"custom_indexes": [], | ||
"base_filter": null, | ||
"check_constraints": [], | ||
"custom_statements": [], | ||
"has_create_action": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters