Skip to content
Snippets Groups Projects
Commit a9c72085 authored by Stephen Mustgrave's avatar Stephen Mustgrave
Browse files

Issue #3385862 by rollins, mmenavas, sarwan_verma, ryo ichiyama, anybody,...

Issue #3385862 by rollins, mmenavas, sarwan_verma, ryo ichiyama, anybody, andikanio: Missing primary key in table `restrict_ip_paths' and  `restrict_ip_whitelisted_ip_addresses'
parent d85a52a8
No related branches found
No related tags found
No related merge requests found
Pipeline #377972 failed
......@@ -16,11 +16,13 @@ function restrict_ip_schema(): array {
'description' => 'A Whitelisted IP address',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
],
'indexes' => [
'ip_address' => ['ip_address'],
],
'primary key' => ['ip_address'],
];
$schema['restrict_ip_paths'] = [
......@@ -35,11 +37,13 @@ function restrict_ip_schema(): array {
'description' => 'The path to be white/blacklisted',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
],
'indexes' => [
'type_path' => ['type', 'path'],
],
'primary key' => ['path'],
];
return $schema;
......@@ -115,3 +119,19 @@ function restrict_ip_update_8002(): void {
],
]);
}
/**
* Add primary keys for tables.
*/
function restrict_ip_update_500001(): void {
$schema = \Drupal::database()->schema();
if (!$schema->indexExists('restrict_ip_paths', 'PRIMARY')) {
// Add primary key to "restrict_ip_paths" table.
$schema->addPrimaryKey('restrict_ip_paths', ['path']);
}
if (!$schema->indexExists('restrict_ip_whitelisted_ip_addresses', 'PRIMARY')) {
// Add primary key to "restrict_ip_whitelisted_ip_addresses" table.
$schema->addPrimaryKey('restrict_ip_whitelisted_ip_addresses', ['path']);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment