@@ -, +, @@ --- Koha/Schema/Result/ApiKey.pm | 44 +++++-------------- .../atomicupdate/bug_20568_api_keys.perl | 6 +-- installer/data/mysql/kohastructure.sql | 8 ++-- 3 files changed, 17 insertions(+), 41 deletions(-) --- a/Koha/Schema/Result/ApiKey.pm +++ a/Koha/Schema/Result/ApiKey.pm @@ -23,18 +23,6 @@ __PACKAGE__->table("api_keys"); =head1 ACCESSORS -=head2 id - - data_type: 'integer' - is_auto_increment: 1 - is_nullable: 0 - -=head2 patron_id - - data_type: 'integer' - is_foreign_key: 1 - is_nullable: 0 - =head2 client_id data_type: 'varchar' @@ -53,6 +41,12 @@ __PACKAGE__->table("api_keys"); is_nullable: 0 size: 255 +=head2 patron_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + =head2 active data_type: 'tinyint' @@ -62,16 +56,14 @@ __PACKAGE__->table("api_keys"); =cut __PACKAGE__->add_columns( - "id", - { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, - "patron_id", - { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "client_id", { data_type => "varchar", is_nullable => 0, size => 191 }, "secret", { data_type => "varchar", is_nullable => 0, size => 191 }, "description", { data_type => "varchar", is_nullable => 0, size => 255 }, + "patron_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "active", { data_type => "tinyint", default_value => 1, is_nullable => 0 }, ); @@ -80,28 +72,16 @@ __PACKAGE__->add_columns( =over 4 -=item * L +=item * L =back =cut -__PACKAGE__->set_primary_key("id"); +__PACKAGE__->set_primary_key("client_id"); =head1 UNIQUE CONSTRAINTS -=head2 C - -=over 4 - -=item * L - -=back - -=cut - -__PACKAGE__->add_unique_constraint("client_id", ["client_id"]); - =head2 C =over 4 @@ -132,8 +112,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-04-14 00:56:23 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:b7AUAgl2SClXJ2lzPVV0FA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-04-14 14:48:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qnu4QSACpOSQaZgd52ozmw __PACKAGE__->add_columns( '+active' => { is_boolean => 1 } --- a/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl +++ a/installer/data/mysql/atomicupdate/bug_20568_api_keys.perl @@ -4,14 +4,12 @@ if(CheckVersion($DBversion)) { if (!TableExists('api_keys')) { $dbh->do(q{ CREATE TABLE `api_keys` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `patron_id` INT(11) NOT NULL, `client_id` VARCHAR(191) NOT NULL, `secret` VARCHAR(191) NOT NULL, `description` VARCHAR(255) NOT NULL, + `patron_id` INT(11) NOT NULL, `active` TINYINT(1) DEFAULT 1 NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `client_id` (`client_id`), + PRIMARY KEY `client_id` (`client_id`), UNIQUE KEY `secret` (`secret`), KEY `patron_id` (`patron_id`), CONSTRAINT `api_keys_fk_patron_id` --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1719,16 +1719,14 @@ CREATE TABLE borrower_sync ( DROP TABLE IF EXISTS `api_keys`; CREATE TABLE `api_keys` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, -- API key internal identifier - `patron_id` INT(11) NOT NULL, -- Foreign key to the borrowers table `client_id` VARCHAR(191) NOT NULL, -- API client ID `secret` VARCHAR(191) NOT NULL, -- API client secret used for API authentication `description` VARCHAR(255) NOT NULL, -- API client description + `patron_id` INT(11) NOT NULL, -- Foreign key to the borrowers table `active` TINYINT(1) DEFAULT 1 NOT NULL, -- 0 means this API key is revoked - PRIMARY KEY (`id`), - KEY `patron_id` (`patron_id`), - UNIQUE KEY `client_id` (`client_id`), + PRIMARY KEY `client_id` (`client_id`), UNIQUE KEY `secret` (`secret`), + KEY `patron_id` (`patron_id`), CONSTRAINT `api_keys_fk_patron_id` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) --