diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-04-30 18:05:07 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-04-30 18:05:07 +0200 |
commit | 048767149e571469d888ec81d324caa7b3b64671 (patch) | |
tree | d713208b260e83b9b134b48d61cf2817718efde0 /lib/Travelynx/Command/database.pm | |
parent | a57a24c2d68daa4d4561ed9035c863e574cdc70a (diff) |
use a separate table for registration tokens
Diffstat (limited to 'lib/Travelynx/Command/database.pm')
-rw-r--r-- | lib/Travelynx/Command/database.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm index 05b43d6..79ff086 100644 --- a/lib/Travelynx/Command/database.pm +++ b/lib/Travelynx/Command/database.pm @@ -424,6 +424,38 @@ my @migrations = ( } ); }, + + # v9 -> v10 + # Add pending_registrations table. The users.token column is no longer + # needed. + sub { + my ($db) = @_; + $db->query( + qq{ + create table pending_registrations ( + user_id integer not null references users (id) primary key, + token varchar(80) not null + ); + comment on table pending_registrations is 'Verification tokens for newly registered accounts'; + update schema_version set version = 10; + } + ); + my $res = $db->select( 'users', [ 'id', 'token' ], { status => 0 } ); + for my $user ( $res->hashes->each ) { + $db->insert( + 'pending_registrations', + { + user_id => $user->{id}, + token => $user->{token} + } + ); + } + $db->query( + qq{ + alter table users drop column token; + } + ); + }, ); sub setup_db { |