mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 12:52:55 +12:00
improvement(TokenResource)!: rename generated created_at
attribute to inserted_at
.
If you are using the token resource this is a **breaking change**. You will need to generate new migrations using: mix ash_postgres.generate_migrations --name=rename_created_at_to_inserted_at It will ask you if you are renaming `created_at` to `inserted_at` - answer yes.
This commit is contained in:
parent
2780c712aa
commit
07f9408eee
8 changed files with 307 additions and 6 deletions
|
@ -63,7 +63,7 @@ defmodule AshAuthentication.TokenResource.Transformer do
|
|||
writable?: true
|
||||
),
|
||||
{:ok, dsl_state} <-
|
||||
maybe_build_attribute(dsl_state, :created_at, :utc_datetime_usec,
|
||||
maybe_build_attribute(dsl_state, :inserted_at, :utc_datetime_usec,
|
||||
allow_nil?: false,
|
||||
private?: true,
|
||||
default: &DateTime.utc_now/0
|
||||
|
@ -73,6 +73,7 @@ defmodule AshAuthentication.TokenResource.Transformer do
|
|||
allow_nil?: false,
|
||||
private?: true,
|
||||
default: &DateTime.utc_now/0,
|
||||
match_other_defaults?: true,
|
||||
update_default: &DateTime.utc_now/0
|
||||
),
|
||||
:ok <- validate_extra_data_field(dsl_state),
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
defmodule Example.Repo.Migrations.RenameCreatedAtToInsertedAt 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
|
||||
rename table(:user_with_token_required), :created_at, to: :inserted_at
|
||||
|
||||
rename table(:user), :created_at, to: :inserted_at
|
||||
|
||||
rename table(:tokens), :created_at, to: :inserted_at
|
||||
end
|
||||
|
||||
def down do
|
||||
rename table(:tokens), :inserted_at, to: :created_at
|
||||
|
||||
rename table(:user), :inserted_at, to: :created_at
|
||||
|
||||
rename table(:user_with_token_required), :inserted_at, to: :created_at
|
||||
end
|
||||
end
|
89
priv/resource_snapshots/repo/tokens/20230921214515.json
Normal file
89
priv/resource_snapshots/repo/tokens/20230921214515.json
Normal file
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"attributes": [
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "updated_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "inserted_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "extra_data",
|
||||
"type": "map"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "purpose",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "expires_at",
|
||||
"type": "utc_datetime"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "subject",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": true,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "jti",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"base_filter": null,
|
||||
"check_constraints": [],
|
||||
"custom_indexes": [],
|
||||
"custom_statements": [],
|
||||
"has_create_action": true,
|
||||
"hash": "25131200B3413B973EF0B7756EBA3FE5C2A7BB5DFE4570E821B040E67D56C858",
|
||||
"identities": [],
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"repo": "Elixir.Example.Repo",
|
||||
"schema": null,
|
||||
"table": "tokens"
|
||||
}
|
108
priv/resource_snapshots/repo/user/20230921214515.json
Normal file
108
priv/resource_snapshots/repo/user/20230921214515.json
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"attributes": [
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "confirmed_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"uuid_generate_v4()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": true,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "id",
|
||||
"type": "uuid"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "username",
|
||||
"type": "citext"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "extra_stuff",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "not_accepted_extra_stuff",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "hashed_password",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "inserted_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "updated_at",
|
||||
"type": "utc_datetime_usec"
|
||||
}
|
||||
],
|
||||
"base_filter": null,
|
||||
"check_constraints": [],
|
||||
"custom_indexes": [],
|
||||
"custom_statements": [],
|
||||
"has_create_action": true,
|
||||
"hash": "E3D96D702989FA5E11CDA575DDD6A4EEADCCCFEBB1C1A0D319E75699C0F92172",
|
||||
"identities": [
|
||||
{
|
||||
"base_filter": null,
|
||||
"index_name": "user_username_index",
|
||||
"keys": [
|
||||
"username"
|
||||
],
|
||||
"name": "username"
|
||||
}
|
||||
],
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"repo": "Elixir.Example.Repo",
|
||||
"schema": null,
|
||||
"table": "user"
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"attributes": [
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"uuid_generate_v4()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": true,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "id",
|
||||
"type": "uuid"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "email",
|
||||
"type": "citext"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "hashed_password",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "inserted_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"now()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "updated_at",
|
||||
"type": "utc_datetime_usec"
|
||||
}
|
||||
],
|
||||
"base_filter": null,
|
||||
"check_constraints": [],
|
||||
"custom_indexes": [],
|
||||
"custom_statements": [],
|
||||
"has_create_action": true,
|
||||
"hash": "FDF27DC116615A2B66AE8B12AD9152E5F3AB41926FA406C4656F92CB4C1167B0",
|
||||
"identities": [
|
||||
{
|
||||
"base_filter": null,
|
||||
"index_name": "user_with_token_required_email_index",
|
||||
"keys": [
|
||||
"email"
|
||||
],
|
||||
"name": "email"
|
||||
}
|
||||
],
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"repo": "Elixir.Example.Repo",
|
||||
"schema": null,
|
||||
"table": "user_with_token_required"
|
||||
}
|
|
@ -72,7 +72,7 @@ defmodule AshAuthentication.AddOn.Confirmation.ActionsTest do
|
|||
query =
|
||||
from(t in Example.Token,
|
||||
where: t.purpose == "confirm",
|
||||
order_by: [desc: t.created_at],
|
||||
order_by: [desc: t.inserted_at],
|
||||
limit: 1
|
||||
)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule Example.User do
|
|||
id: Ecto.UUID.t(),
|
||||
username: String.t(),
|
||||
hashed_password: String.t(),
|
||||
created_at: DateTime.t(),
|
||||
inserted_at: DateTime.t(),
|
||||
updated_at: DateTime.t()
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ defmodule Example.User do
|
|||
attribute :not_accepted_extra_stuff, :string
|
||||
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true, private?: true
|
||||
|
||||
create_timestamp :created_at
|
||||
create_timestamp :inserted_at
|
||||
update_timestamp :updated_at
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ defmodule Example.UserWithTokenRequired do
|
|||
id: Ecto.UUID.t(),
|
||||
email: String.t(),
|
||||
hashed_password: String.t(),
|
||||
created_at: DateTime.t(),
|
||||
inserted_at: DateTime.t(),
|
||||
updated_at: DateTime.t()
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ defmodule Example.UserWithTokenRequired do
|
|||
uuid_primary_key :id, writable?: true
|
||||
attribute :email, :ci_string, allow_nil?: false
|
||||
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true, private?: true
|
||||
create_timestamp :created_at
|
||||
create_timestamp :inserted_at
|
||||
update_timestamp :updated_at
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue