Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
446ff40c
Commit
446ff40c
authored
15 years ago
by
Jérôme David
Browse files
Options
Downloads
Patches
Plain Diff
database upgrade code has been modified in order to be generic.
parent
03922be7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fr/inrialpes/exmo/align/service/CacheImpl.java
+60
-20
60 additions, 20 deletions
src/fr/inrialpes/exmo/align/service/CacheImpl.java
with
60 additions
and
20 deletions
src/fr/inrialpes/exmo/align/service/CacheImpl.java
+
60
−
20
View file @
446ff40c
...
...
@@ -73,12 +73,12 @@ public class CacheImpl {
final
int
VERSION
=
400
;
// Version of the API to be stored in the database
/* 300: initial database format
301: added alignment id as primary key
302:
change
d cached/stored/ouri tag forms
310:
change
d extension table with added URIs and method -> val
340:
change
d size of relation in cell table (5 -> 25)
400:
change
d size of relation in cell table (5 -> 255 because of URIs)
change
d all URI size to 255
change
d level size to 25
302:
ALTER
d cached/stored/ouri tag forms
310:
ALTER
d extension table with added URIs and method -> val
340:
ALTER
d size of relation in cell table (5 -> 25)
400:
ALTER
d size of relation in cell table (5 -> 255 because of URIs)
ALTER
d all URI size to 255
ALTER
d level size to 25
added cell_id as keys?
*/
...
...
@@ -756,6 +756,26 @@ public class CacheImpl {
pst
.
executeUpdate
();
pst
.
close
();
}
/*
* A dummy method, since it exists just ALTER TABLE ... DROP and ALTER TABLE ... ADD in SQL Language.
* each dbms has its own language for manipulating table columns....
*/
public
void
renameColumn
(
Statement
st
,
String
tableName
,
String
oldName
,
String
newName
,
String
newType
)
throws
SQLException
{
st
.
executeUpdate
(
"ALTER TABLE "
+
tableName
+
" ADD "
+
newName
+
" "
+
newType
);
st
.
executeUpdate
(
"UPDATE "
+
tableName
+
" SET "
+
newName
+
"="
+
oldName
);
st
.
executeUpdate
(
"ALTER TABLE "
+
tableName
+
" DROP "
+
oldName
);
}
/*
* Another dummy method, since it exists just ALTER TABLE ... DROP and ALTER TABLE ... ADD in SQL Language.
* each dbms has its own language for manipulating table columns....
*/
public
void
changeColumnType
(
Statement
st
,
String
tableName
,
String
columnName
,
String
newType
)
throws
SQLException
{
String
tempName
=
columnName
+
"temp"
;
renameColumn
(
st
,
tableName
,
columnName
,
tempName
,
newType
);
renameColumn
(
st
,
tableName
,
tempName
,
columnName
,
newType
);
}
public
void
updateDatabase
()
throws
SQLException
,
AlignmentException
{
Statement
st
=
createStatement
();
...
...
@@ -766,8 +786,11 @@ public class CacheImpl {
if
(
version
<
VERSION
)
{
if
(
version
>=
302
)
{
if
(
version
<
310
)
{
// Change database
st
.
executeUpdate
(
"ALTER TABLE extension CHANGE method val VARCHAR(500)"
);
// ALTER database
renameColumn
(
st
,
"extension"
,
"method"
,
"val"
,
"VARCHAR(500)"
);
// case mysql
//st.executeUpdate("ALTER TABLE extension CHANGE method val VARCHAR(500)");
st
.
executeUpdate
(
"ALTER TABLE extension ADD uri VARCHAR(200);"
);
// Modify extensions
ResultSet
rse
=
st
.
executeQuery
(
"SELECT * FROM extension"
);
...
...
@@ -799,19 +822,36 @@ public class CacheImpl {
}
// Nothing to do with 340: subsumed by 400
if
(
version
<
400
)
{
// Change database
st
.
executeUpdate
(
"ALTER TABLE cell CHANGE relation relation VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE cell CHANGE uri1 uri1 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE cell CHANGE uri2 uri2 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE level level VARCHAR(25)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE uri1 uri1 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE uri2 uri2 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE file1 file1 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE file2 file2 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE owlontology1 ontology1 VARCHAR(255)"
);
st
.
executeUpdate
(
"ALTER TABLE alignment CHANGE owlontology2 ontology2 VARCHAR(255)"
);
// ALTER database
/*
st.executeUpdate("ALTER TABLE cell CHANGE relation relation VARCHAR(255)");
st.executeUpdate("ALTER TABLE cell CHANGE uri1 uri1 VARCHAR(255)");
st.executeUpdate("ALTER TABLE cell CHANGE uri2 uri2 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE level level VARCHAR(25)");
st.executeUpdate("ALTER TABLE alignment CHANGE uri1 uri1 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE uri2 uri2 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE file1 file1 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE file2 file2 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE owlontology1 ontology1 VARCHAR(255)");
st.executeUpdate("ALTER TABLE alignment CHANGE owlontology2 ontology2 VARCHAR(255)");
*/
changeColumnType
(
st
,
"cell"
,
"relation"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"cell"
,
"uri1"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"cell"
,
"uri2"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"alignment"
,
"level"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"alignment"
,
"uri1"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"alignment"
,
"uri2"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"alignment"
,
"file1"
,
"VARCHAR(255)"
);
changeColumnType
(
st
,
"alignment"
,
"file2"
,
"VARCHAR(255)"
);
renameColumn
(
st
,
"alignment"
,
"owlontology1"
,
"ontology1"
,
"VARCHAR(255)"
);
renameColumn
(
st
,
"alignment"
,
"owlontology2"
,
"ontology2"
,
"VARCHAR(255)"
);
}
//
Change
version
//
ALTER
version
st
.
executeUpdate
(
"UPDATE server SET version='"
+
VERSION
+
"' WHERE port='port'"
);
}
else
{
throw
new
AlignmentException
(
"Database must be upgraded ("
+
version
+
" -> "
+
VERSION
+
")"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment