Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.9
obs-server
obs-server-2.9-0035-frontend-Rails-5.2-Add-a-pr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File obs-server-2.9-0035-frontend-Rails-5.2-Add-a-primary-key-to-data-migrati.patch of Package obs-server
From 490f20f1c335d7f2b95496282115ca18f65a65da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= <bgeuken@suse.de> Date: Wed, 23 May 2018 14:59:39 +0200 Subject: [PATCH] [frontend] Rails 5.2: Add a primary key to data migration table With the recent rails update our structure sql test would dump out a different schema for the data migration tabel than we have in existing OBS instances: ` CREATE TABLE `data_migrations` ( `version` varchar(255) NOT NULL, - UNIQUE KEY `unique_data_migrations` (`version`) + PRIMARY KEY (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ` Created with `rake docker:test:lint`. This commit provides a migration that replaces the existing index with a primary key. That way existing OBS DB schemas will stay in sync with schemas of newly created DBs. --- ...0523123532_add_primary_key_to_data_migrations.rb | 13 +++++++++++++ src/api/db/structure.sql | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/api/db/migrate/20180523123532_add_primary_key_to_data_migrations.rb diff --git a/src/api/db/migrate/20180523123532_add_primary_key_to_data_migrations.rb b/src/api/db/migrate/20180523123532_add_primary_key_to_data_migrations.rb new file mode 100644 index 0000000000..5c13962dbf --- /dev/null +++ b/src/api/db/migrate/20180523123532_add_primary_key_to_data_migrations.rb @@ -0,0 +1,13 @@ +class AddPrimaryKeyToDataMigrations < ActiveRecord::Migration[5.1] + def up + change_column :data_migrations, :version, :string, limit: 255, primary_key: true if primary_keys(:data_migrations).empty? + return unless index_exists?(:data_migrations, :version, name: :unique_data_migrations) + remove_index :data_migrations, name: :unique_data_migrations + end + + def down + execute('alter table data_migrations DROP PRIMARY KEY') unless primary_keys(:data_migrations).empty? + return if index_exists?(:data_migrations, :version, name: :unique_data_migrations) + add_index :data_migrations, :version, name: :unique_data_migrations, unique: true + end +end diff --git a/src/api/db/structure.sql b/src/api/db/structure.sql index 188e73d4fe..8aab31f14e 100644 --- a/src/api/db/structure.sql +++ b/src/api/db/structure.sql @@ -399,7 +399,7 @@ CREATE TABLE `configurations` ( CREATE TABLE `data_migrations` ( `version` varchar(255) NOT NULL, - UNIQUE KEY `unique_data_migrations` (`version`) + PRIMARY KEY (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `delayed_jobs` ( @@ -1315,7 +1315,8 @@ INSERT INTO `schema_migrations` (version) VALUES ('20171219122451'), ('20180109115548'), ('20180110074142'), -('20180307074538'); +('20180307074538'), +('20180523123532'), ('20180815091004'); -- 2.20.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor