I'm currently trying to use the solution found here, but I don't seem to be able to change the type of the users column from date
to integer
.
When I try:
ALTER TABLE users ALTER COLUMN password_reset_expires TYPE integer;
I get this error:
ERROR: column "password_reset_expires" cannot be cast automatically to type integer HINT: You might need to specify "USING password_reset_expires::integer".
And when I try:
ALTER TABLE users ALTER COLUMN password_reset_expires TYPE integer
USING (password_reset_expires::integer);
The error tells me:
ERROR: cannot cast type date to integer LINE 1: ...expires TYPE integer USING (password_reset_expires::integer)...
My table definition:
Table "public.users"
Column | Type | Collation | Nullable | Default
------------------------+------------------------+-----------+----------+-----------------------------------
id | bigint | | not null | nextval('users_id_seq'::regclass)
name | character varying(20) | | not null |
email | character varying(100) | | not null |
password | character varying(500) | | not null |
password_changed_at | date | | |
password_reset_token | character varying(300) | | |
password_reset_expires | date | | |
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "tokens" CONSTRAINT "tokens_token_pk_fkey" FOREIGN KEY (fk_users_id) REFERENCES users(id)
Here is one of my user objects:
{
id: '59',
name: 'visitor',
email: 'visitor',
password: '$2b$10$0UGgdRUlXFYeQfk5Nv/vXe9khdzyyOqsTiFGyNXLfEDuOFAt0xc1G',
password_changed_at: null,
password_reset_token: null,
password_reset_expires: null
}