Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit eda45ad4 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the script fix_affiliation_keys_0960.py to update existing database.

parent 1502376b
-- MySQL dump 10.14 Distrib 5.5.43-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: test_publications
-- ------------------------------------------------------
-- Server version 5.5.43-MariaDB
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `affiliation_keys`
--
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `affiliation_keys` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`key_u` varchar(255) NOT NULL,
`key_v` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Dump completed on 2016-09-21 14:49:52
# -*- coding: utf-8 -*-
""" NAME
fix_affiliation_keys_0960 -- create the affiliation_keys table
SYNOPSIS
fix_affiliation_keys_0960
DESCRIPTION
A new mechanism was introduced in version 0.9.6.0 in order to
deal with affiliation. It relies on a new database table
affiliation_keys. Preferences inspihep_institure_id and
add_rules_reg_institute are obsolete and have to be removed.
The aim of this script, is to update existing database.
OPTIONS
EXAMPLE
> cd ...limbra/scripts
> ./run script fix_affiliation_keys_0960.py
> ./run -S limbra_cppm script fix_affiliation_keys_0960.py
> ./run loop fix_affiliation_keys_0960
AUTHOR
R. Le Gac -- Sep 2016
"""
if __name__ == "__main__":
import sys
import os
# protection: exit if the table affiliation_keys exists
if "affiliation_keys" in db.tables:
print "\n\tThe table affiliation_keys already exists. Exit\n"
sys.exit(1)
# create the database table affiliation_keys from SQL statement
print "\n\tCreate the table affiliation_keys"
fn = os.path.join(os.getcwd(),
"applications",
request.application,
"scripts",
"affiliation_keys_0960.sql")
with open(fn) as fi:
db.executesql(fi.read())
# remove preferences inspihep_institure_id, add_rules_reg_institute
for pref in ("inspihep_institure_id", "add_rules_reg_institute"):
print "\tRemove preference", pref
db(db.preferences.property == pref).delete()
db.commit()
# exit
print "\n\tEnd of script\n"
sys.exit(0)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment