Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
eda45ad4
Commit
eda45ad4
authored
Sep 21, 2016
by
LE GAC Renaud
Browse files
Add the script fix_affiliation_keys_0960.py to update existing database.
parent
1502376b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
scripts/affiliation_keys_0960.sql
scripts/affiliation_keys_0960.sql
+32
-0
scripts/fix_affiliation_keys_0960.py
scripts/fix_affiliation_keys_0960.py
+58
-0
No files found.
scripts/affiliation_keys_0960.sql
0 → 100644
View file @
eda45ad4
-- 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
scripts/fix_affiliation_keys_0960.py
0 → 100644
View file @
eda45ad4
# -*- 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\t
The table affiliation_keys already exists. Exit
\n
"
sys
.
exit
(
1
)
# create the database table affiliation_keys from SQL statement
print
"
\n\t
Create 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
"
\t
Remove preference"
,
pref
db
(
db
.
preferences
.
property
==
pref
).
delete
()
db
.
commit
()
# exit
print
"
\n\t
End of script
\n
"
sys
.
exit
(
0
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment