Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
43ccbe69
Unverified
Commit
43ccbe69
authored
Feb 16, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔖
v2.9.9 to v3.0.0 升级程序
parent
40dd2c24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
src/main/java/org/b3log/solo/service/UpgradeService.java
src/main/java/org/b3log/solo/service/UpgradeService.java
+25
-24
No files found.
src/main/java/org/b3log/solo/service/UpgradeService.java
View file @
43ccbe69
...
@@ -58,7 +58,7 @@ import java.util.Set;
...
@@ -58,7 +58,7 @@ import java.util.Set;
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @version 1.2.0.3
5, Feb 8
, 2019
* @version 1.2.0.3
6, Feb 16
, 2019
* @since 1.2.0
* @since 1.2.0
*/
*/
@Service
@Service
...
@@ -82,7 +82,7 @@ public class UpgradeService {
...
@@ -82,7 +82,7 @@ public class UpgradeService {
/**
/**
* Old version.
* Old version.
*/
*/
private
static
final
String
FROM_VER
=
"2.9.
8
"
;
private
static
final
String
FROM_VER
=
"2.9.
9
"
;
/**
/**
* New version.
* New version.
...
@@ -159,7 +159,7 @@ public class UpgradeService {
...
@@ -159,7 +159,7 @@ public class UpgradeService {
}
}
if
(
FROM_VER
.
equals
(
currentVer
))
{
if
(
FROM_VER
.
equals
(
currentVer
))
{
perform
();
perform
299_300
();
return
;
return
;
}
}
...
@@ -180,15 +180,25 @@ public class UpgradeService {
...
@@ -180,15 +180,25 @@ public class UpgradeService {
}
}
/**
/**
* Performs upgrade.
* Performs upgrade
from v2.9.9 to v3.0.0
.
*
*
* @throws Exception upgrade fails
* @throws Exception upgrade fails
*/
*/
private
void
perform
()
throws
Exception
{
private
void
perform
299_300
()
throws
Exception
{
LOGGER
.
log
(
Level
.
INFO
,
"Upgrading from version [{0}] to version [{1}]...."
,
FROM_VER
,
TO_VER
);
LOGGER
.
log
(
Level
.
INFO
,
"Upgrading from version [{0}] to version [{1}]...."
,
FROM_VER
,
TO_VER
);
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
try
{
try
{
Connection
connection
=
Connections
.
getConnection
();
Statement
statement
=
connection
.
createStatement
();
final
String
tablePrefix
=
Latkes
.
getLocalProperty
(
"jdbc.tablePrefix"
)
+
"_"
;
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"user` ADD COLUMN `userB3Key` VARCHAR(64) NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"user` ADD COLUMN `userGitHubId` VARCHAR(32) NOT NULL"
);
statement
.
close
();
connection
.
commit
();
connection
.
close
();
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
final
JSONObject
versionOpt
=
optionRepository
.
get
(
Option
.
ID_C_VERSION
);
final
JSONObject
versionOpt
=
optionRepository
.
get
(
Option
.
ID_C_VERSION
);
versionOpt
.
put
(
Option
.
OPTION_VALUE
,
TO_VER
);
versionOpt
.
put
(
Option
.
OPTION_VALUE
,
TO_VER
);
optionRepository
.
update
(
Option
.
ID_C_VERSION
,
versionOpt
);
optionRepository
.
update
(
Option
.
ID_C_VERSION
,
versionOpt
);
...
@@ -208,7 +218,7 @@ public class UpgradeService {
...
@@ -208,7 +218,7 @@ public class UpgradeService {
}
}
optionRepository
.
remove
(
"oauthGitHub"
);
optionRepository
.
remove
(
"oauthGitHub"
);
final
JSONObject
b3Key
=
optionRepository
.
get
(
"keyOfSolo"
);
final
String
b3Key
=
optionRepository
.
get
(
"keyOfSolo"
).
optString
(
Option
.
OPTION_VALUE
);
final
JSONObject
admin
=
userRepository
.
getAdmin
();
final
JSONObject
admin
=
userRepository
.
getAdmin
();
admin
.
put
(
UserExt
.
USER_B3_KEY
,
b3Key
);
admin
.
put
(
UserExt
.
USER_B3_KEY
,
b3Key
);
userRepository
.
update
(
admin
.
optString
(
Keys
.
OBJECT_ID
),
admin
);
userRepository
.
update
(
admin
.
optString
(
Keys
.
OBJECT_ID
),
admin
);
...
@@ -226,14 +236,17 @@ public class UpgradeService {
...
@@ -226,14 +236,17 @@ public class UpgradeService {
optionRepository
.
remove
(
"editorType"
);
optionRepository
.
remove
(
"editorType"
);
transaction
.
commit
();
transaction
.
commit
();
dropColumns
();
connection
=
Connections
.
getConnection
();
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleEditorType`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"page` DROP COLUMN `pageEditorType`"
);
statement
.
close
();
connection
.
commit
();
connection
.
close
();
LOGGER
.
log
(
Level
.
INFO
,
"Upgraded from version [{0}] to version [{1}] successfully :-)"
,
FROM_VER
,
TO_VER
);
LOGGER
.
log
(
Level
.
INFO
,
"Upgraded from version [{0}] to version [{1}] successfully :-)"
,
FROM_VER
,
TO_VER
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
}
LOGGER
.
log
(
Level
.
ERROR
,
"Upgrade failed!"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Upgrade failed!"
,
e
);
throw
new
Exception
(
"Upgrade failed from version ["
+
FROM_VER
+
"] to version ["
+
TO_VER
+
']'
);
throw
new
Exception
(
"Upgrade failed from version ["
+
FROM_VER
+
"] to version ["
+
TO_VER
+
']'
);
...
@@ -258,18 +271,6 @@ public class UpgradeService {
...
@@ -258,18 +271,6 @@ public class UpgradeService {
connection
.
close
();
connection
.
close
();
}
}
private
void
dropColumns
()
throws
Exception
{
final
Connection
connection
=
Connections
.
getConnection
();
final
Statement
statement
=
connection
.
createStatement
();
final
String
tablePrefix
=
Latkes
.
getLocalProperty
(
"jdbc.tablePrefix"
)
+
"_"
;
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleEditorType`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"page` DROP COLUMN `pageEditorType`"
);
statement
.
close
();
connection
.
commit
();
connection
.
close
();
}
private
void
dropTables
()
throws
Exception
{
private
void
dropTables
()
throws
Exception
{
final
Connection
connection
=
Connections
.
getConnection
();
final
Connection
connection
=
Connections
.
getConnection
();
final
Statement
statement
=
connection
.
createStatement
();
final
Statement
statement
=
connection
.
createStatement
();
...
...
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