Skip to content
Snippets Groups Projects
Verified Commit 8d71de1a authored by David Gunnarsson's avatar David Gunnarsson
Browse files

Merge SQL view fabric_code_names to db

this view is needed for searches, so migrating it is needed
parent f1282fda
No related branches found
No related tags found
No related merge requests found
class AddFabricCodeNamesView < ActiveRecord::Migration[8.0]
def up
# Drop the table if it exists
execute "DROP TABLE IF EXISTS `fabric_code_names`"
# Create the view
execute <<-SQL
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `fabric_code_names`
AS SELECT
`fabric_codes`.`ID` AS `id`,
lcase(concat_ws('-',
convert(ifnull(`gazetteer`.`code`, `gazetteer`.`name`) using utf8),
convert(ifnull(`wares`.`code`, `wares`.`name`) using utf8),
cast(`fabric_codes`.`serial_number` as char charset utf8)
)) AS `name`
FROM ((`fabric_codes`
join `gazetteer` on((`gazetteer`.`ID` = `fabric_codes`.`provenience_id`)))
join `wares` on((`wares`.`ID` = `fabric_codes`.`ware_id`)))
SQL
end
def down
# Drop the view
execute "DROP VIEW IF EXISTS `fabric_code_names`"
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_03_24_145042) do ActiveRecord::Schema[8.0].define(version: 2025_04_09_101745) do
create_table "actor_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "actor_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "actor_type" t.string "actor_type"
t.datetime "created_at", null: false t.datetime "created_at", null: false
......
# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.1.73)
# Datenbank: facem
# Erstellt am: 2023-01-11 12:28:27 +0000
# ************************************************************
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40000 ALTER TABLE `images` ENABLE KEYS */;
UNLOCK TABLES;
# Replace placeholder table for fabric_code_names with correct view syntax
# ------------------------------------------------------------
DROP TABLE `fabric_code_names`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `fabric_code_names`
AS SELECT
`fabric_codes`.`ID` AS `id`,lcase(concat_ws('-',convert(ifnull(`gazetteer`.`code`,
`gazetteer`.`name`) using utf8),convert(ifnull(`wares`.`code`,
`wares`.`name`) using utf8),cast(`fabric_codes`.`serial_number` as char charset utf8))) AS `name`
FROM ((`fabric_codes` join `gazetteer` on((`gazetteer`.`ID` = `fabric_codes`.`provenience_id`))) join `wares` on((`wares`.`ID` = `fabric_codes`.`ware_id`)));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment