File obs-server-2.10-0116-Fix-precision-of-field-created_at-in-internal-table.patch of Package obs-server

From 79345f42458356521501717ebc11aea9456156d8 Mon Sep 17 00:00:00 2001
From: Eduardo Navarro <enavarro@suse.com>
Date: Thu, 2 Apr 2020 16:23:32 +0200
Subject: [PATCH] Fix precision of field 'created_at' in internal table

The default precision of created_at and updated_at fields have changed
in Rails 6. This change is needed to upgrade to Rails 6.

Co-authored-by: Lukas Krause <lkrause@suse.de>
---
 ...hange_datetime_precision_ar_internal_metadata.rb | 13 +++++++++++++
 src/api/db/structure.sql                            |  5 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 src/api/db/migrate/20200402141344_change_datetime_precision_ar_internal_metadata.rb

diff --git a/src/api/db/migrate/20200402141344_change_datetime_precision_ar_internal_metadata.rb b/src/api/db/migrate/20200402141344_change_datetime_precision_ar_internal_metadata.rb
new file mode 100644
index 0000000000..5647e82ee1
--- /dev/null
+++ b/src/api/db/migrate/20200402141344_change_datetime_precision_ar_internal_metadata.rb
@@ -0,0 +1,13 @@
+class ChangeDatetimePrecisionArInternalMetadata < ActiveRecord::Migration[6.0]
+  def change
+    reversible do |direction|
+      direction.up do
+        safety_assured { change_column :ar_internal_metadata, :created_at, :datetime, limit: 6 }
+      end
+
+      direction.down do
+        change_column :ar_internal_metadata, :created_at, :datetime
+      end
+    end
+  end
+end
diff --git a/src/api/db/structure.sql b/src/api/db/structure.sql
index 05c22c6a82..46ef87aafc 100644
--- a/src/api/db/structure.sql
+++ b/src/api/db/structure.sql
@@ -19,7 +19,7 @@ CREATE TABLE `announcements_users` (
 CREATE TABLE `ar_internal_metadata` (
   `key` varchar(255) CHARACTER SET utf8 NOT NULL,
   `value` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
-  `created_at` datetime NOT NULL,
+  `created_at` datetime(6) NOT NULL,
   `updated_at` datetime(6) NOT NULL,
   PRIMARY KEY (`key`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
@@ -1456,6 +1456,7 @@ INSERT INTO `schema_migrations` (version) VALUES
 ('20190215131711'),
 ('20190328131711'),
 ('20190412130831'),
-('20190520130009');
+('20190520130009'),
+('20200402141344');
 
 
-- 
2.31.1