=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'
is_nullable: 0
size: 255
+=head2 patron_id
+
+ data_type: 'integer'
+ is_foreign_key: 1
+ is_nullable: 0
+
=head2 active
data_type: 'tinyint'
=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 },
);
=over 4
-=item * L</id>
+=item * L</client_id>
=back
=cut
-__PACKAGE__->set_primary_key("id");
+__PACKAGE__->set_primary_key("client_id");
=head1 UNIQUE CONSTRAINTS
-=head2 C<client_id>
-
-=over 4
-
-=item * L</client_id>
-
-=back
-
-=cut
-
-__PACKAGE__->add_unique_constraint("client_id", ["client_id"]);
-
=head2 C<secret>
=over 4
);
-# 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 }
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`
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`)
if ( $op eq 'delete' ) {
my $api_key_id = $cgi->param('key');
- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $api_key_id });
if ($key) {
$key->delete;
}
if ( $op eq 'revoke' ) {
my $api_key_id = $cgi->param('key');
- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $api_key_id });
if ($key) {
$key->active(0);
$key->store;
if ( $op eq 'activate' ) {
my $api_key_id = $cgi->param('key');
- my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
+ my $key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $api_key_id });
if ($key) {
$key->active(1);
$key->store;
if ($op eq 'delete') {
my $key_id = $cgi->param('key');
- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id });
if ($api_key) {
$api_key->delete;
}
if ($op eq 'revoke') {
my $key_id = $cgi->param('key');
- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id });
if ($api_key) {
$api_key->active(0);
$api_key->store;
if ($op eq 'activate') {
my $key_id = $cgi->param('key');
- my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
+ my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, client_id => $key_id });
if ($api_key) {
$api_key->active(1);
$api_key->store;