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
cf8360da
Unverified
Commit
cf8360da
authored
Sep 16, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
#12509 H2Database 处理
parent
24432b8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
10 deletions
+24
-10
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+2
-2
src/main/java/org/b3log/solo/service/UpgradeService.java
src/main/java/org/b3log/solo/service/UpgradeService.java
+22
-8
No files found.
src/main/java/org/b3log/solo/service/InitService.java
View file @
cf8360da
...
@@ -200,8 +200,8 @@ public class InitService {
...
@@ -200,8 +200,8 @@ public class InitService {
if
(
Latkes
.
RuntimeDatabase
.
H2
==
Latkes
.
getRuntimeDatabase
())
{
if
(
Latkes
.
RuntimeDatabase
.
H2
==
Latkes
.
getRuntimeDatabase
())
{
String
dataDir
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
String
dataDir
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
dataDir
=
dataDir
.
replace
(
"~"
,
System
.
getProperty
(
"user.home"
));
dataDir
=
dataDir
.
replace
(
"~"
,
System
.
getProperty
(
"user.home"
));
LOGGER
.
log
(
Level
.
INFO
,
"Y
OUR
DATA will be stored in directory ["
+
dataDir
+
"], "
LOGGER
.
log
(
Level
.
INFO
,
"Y
our
DATA will be stored in directory ["
+
dataDir
+
"], "
+
"please pay more attention
to it~
"
);
+
"please pay more attention
on it!
"
);
}
}
final
List
<
CreateTableResult
>
createTableResults
=
JdbcRepositories
.
initAllTables
();
final
List
<
CreateTableResult
>
createTableResults
=
JdbcRepositories
.
initAllTables
();
...
...
src/main/java/org/b3log/solo/service/UpgradeService.java
View file @
cf8360da
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
*/
*/
package
org
.
b3log
.
solo
.
service
;
package
org
.
b3log
.
solo
.
service
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.ioc.inject.Inject
;
import
org.b3log.latke.ioc.inject.Inject
;
...
@@ -223,10 +224,10 @@ public class UpgradeService {
...
@@ -223,10 +224,10 @@ public class UpgradeService {
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archivedate1` RENAME TO `"
+
tablePrefix
+
"archivedate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archivedate1` RENAME TO `"
+
tablePrefix
+
"archivedate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archiveDate_article` RENAME TO `"
+
tablePrefix
+
"archivedate_article1`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archiveDate_article` RENAME TO `"
+
tablePrefix
+
"archivedate_article1`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archivedate_article1` RENAME TO `"
+
tablePrefix
+
"archivedate_article`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"archivedate_article1` RENAME TO `"
+
tablePrefix
+
"archivedate_article`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleAuthorId` VARCHAR(19) NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleAuthorId` VARCHAR(19)
DEFAULT ''
NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleCreated` BIGINT NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleCreated` BIGINT
DEFAULT 0
NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleUpdated` BIGINT NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` ADD `articleUpdated` BIGINT
DEFAULT 0
NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"comment` ADD `commentCreated` BIGINT NOT NULL"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"comment` ADD `commentCreated` BIGINT
DEFAULT 0
NOT NULL"
);
statement
.
close
();
statement
.
close
();
connection
.
commit
();
connection
.
commit
();
connection
.
close
();
connection
.
close
();
...
@@ -237,6 +238,7 @@ public class UpgradeService {
...
@@ -237,6 +238,7 @@ public class UpgradeService {
final
Statement
statement
=
connection
.
createStatement
();
final
Statement
statement
=
connection
.
createStatement
();
final
String
tablePrefix
=
Latkes
.
getLocalProperty
(
"jdbc.tablePrefix"
)
+
"_"
;
final
String
tablePrefix
=
Latkes
.
getLocalProperty
(
"jdbc.tablePrefix"
)
+
"_"
;
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleAuthorEmail`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleCreateDate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleCreateDate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleUpdateDate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"article` DROP COLUMN `articleUpdateDate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"comment` DROP COLUMN `commentDate`"
);
statement
.
executeUpdate
(
"ALTER TABLE `"
+
tablePrefix
+
"comment` DROP COLUMN `commentDate`"
);
...
@@ -290,17 +292,26 @@ public class UpgradeService {
...
@@ -290,17 +292,26 @@ public class UpgradeService {
final
String
articleId
=
articles
.
get
(
i
).
optString
(
Keys
.
OBJECT_ID
);
final
String
articleId
=
articles
.
get
(
i
).
optString
(
Keys
.
OBJECT_ID
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
String
authorEmail
=
article
.
optString
(
Article
.
ARTICLE_T_AUTHOR_EMAIL
);
String
authorEmail
=
article
.
optString
(
Article
.
ARTICLE_T_AUTHOR_EMAIL
);
if
(
StringUtils
.
isBlank
(
authorEmail
))
{
// H2
authorEmail
=
article
.
optString
(
Article
.
ARTICLE_T_AUTHOR_EMAIL
.
toUpperCase
());
}
JSONObject
author
=
userRepository
.
getByEmail
(
authorEmail
);
JSONObject
author
=
userRepository
.
getByEmail
(
authorEmail
);
if
(
null
==
author
)
{
if
(
null
==
author
)
{
author
=
userRepository
.
getAdmin
();
author
=
userRepository
.
getAdmin
();
}
}
article
.
put
(
Article
.
ARTICLE_AUTHOR_ID
,
author
.
optString
(
Keys
.
OBJECT_ID
));
article
.
put
(
Article
.
ARTICLE_AUTHOR_ID
,
author
.
optString
(
Keys
.
OBJECT_ID
));
final
Date
createDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_T_CREATE_DATE
);
Date
createDate
=
(
Date
)
article
.
opt
(
Article
.
ARTICLE_T_CREATE_DATE
);
if
(
null
==
createDate
)
{
// H2
createDate
=
(
Date
)
article
.
opt
(
Article
.
ARTICLE_T_CREATE_DATE
.
toUpperCase
());
}
article
.
put
(
Article
.
ARTICLE_CREATED
,
createDate
.
getTime
());
article
.
put
(
Article
.
ARTICLE_CREATED
,
createDate
.
getTime
());
final
Date
updateDate
=
(
Date
)
article
.
get
(
Article
.
ARTICLE_T_UPDATE_DATE
);
Date
updateDate
=
(
Date
)
article
.
opt
(
Article
.
ARTICLE_T_UPDATE_DATE
);
if
(
null
==
updateDate
)
{
// H2
updateDate
=
(
Date
)
article
.
opt
(
Article
.
ARTICLE_T_UPDATE_DATE
.
toUpperCase
());
}
article
.
put
(
Article
.
ARTICLE_UPDATED
,
updateDate
.
getTime
());
article
.
put
(
Article
.
ARTICLE_UPDATED
,
updateDate
.
getTime
());
articleRepository
.
update
(
articleId
,
article
);
articleRepository
.
update
(
articleId
,
article
);
...
@@ -343,7 +354,10 @@ public class UpgradeService {
...
@@ -343,7 +354,10 @@ public class UpgradeService {
final
JSONObject
comment
=
comments
.
get
(
i
);
final
JSONObject
comment
=
comments
.
get
(
i
);
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
final
String
commentId
=
comment
.
optString
(
Keys
.
OBJECT_ID
);
final
Date
createDate
=
(
Date
)
comment
.
get
(
Comment
.
COMMENT_T_DATE
);
Date
createDate
=
(
Date
)
comment
.
opt
(
Comment
.
COMMENT_T_DATE
);
if
(
null
==
createDate
)
{
// H2
createDate
=
(
Date
)
comment
.
opt
(
Comment
.
COMMENT_T_DATE
.
toUpperCase
());
}
comment
.
put
(
Comment
.
COMMENT_CREATED
,
createDate
.
getTime
());
comment
.
put
(
Comment
.
COMMENT_CREATED
,
createDate
.
getTime
());
commentRepository
.
update
(
commentId
,
comment
);
commentRepository
.
update
(
commentId
,
comment
);
...
...
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