Compare commits
2 Commits
e473c0e522
...
48ff48884b
Author | SHA1 | Date | |
---|---|---|---|
48ff48884b | |||
e502692105 |
61
main.go
61
main.go
@ -42,6 +42,67 @@ func connectToDatabases() {
|
|||||||
} else {
|
} else {
|
||||||
resultsDB = resultsDatabase
|
resultsDB = resultsDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createEditorsTableSQL := `
|
||||||
|
create table if not exists EditorsResults(
|
||||||
|
Id int primary key not null auto_increment,
|
||||||
|
WordpressId int not null,
|
||||||
|
Username nvarchar(100) not null,
|
||||||
|
Email nvarchar(100),
|
||||||
|
IsSuccess BIT not null
|
||||||
|
);`
|
||||||
|
_, editorsTableErr := resultsDB.Exec(createEditorsTableSQL)
|
||||||
|
if editorsTableErr != nil {
|
||||||
|
panic("Could not create editors table.")
|
||||||
|
}
|
||||||
|
|
||||||
|
createCategoryResultsTableSQL := `
|
||||||
|
create table if not exists CategoryResults (
|
||||||
|
Id int primary key not null auto_increment,
|
||||||
|
SlowtwitchId int not null,
|
||||||
|
WordpressId int not null,
|
||||||
|
OldUrl nvarchar(500) not null,
|
||||||
|
OldUrlStatus int,
|
||||||
|
NewUrl nvarchar(500),
|
||||||
|
IsSuccess BIT not null,
|
||||||
|
ErrorMessage nvarchar(1500)
|
||||||
|
);`
|
||||||
|
_, createCategoryResultsTableErr := resultsDB.Exec(createCategoryResultsTableSQL)
|
||||||
|
if createCategoryResultsTableErr != nil {
|
||||||
|
panic("Could not create category results table.")
|
||||||
|
}
|
||||||
|
|
||||||
|
createImageResultsTableSQL := `
|
||||||
|
create table if not exists ImageResults(
|
||||||
|
Id int primary key not null auto_increment,
|
||||||
|
PostId int null,
|
||||||
|
WordpressId int not null,
|
||||||
|
OldUrl nvarchar(500) not null,
|
||||||
|
NewUrl nvarchar(500),
|
||||||
|
IsSuccess BIT not null,
|
||||||
|
ErrorMessage nvarchar(1500),
|
||||||
|
foreign key (PostId) references PostResults(Id)
|
||||||
|
);`
|
||||||
|
_, createImageResultsTableErr := resultsDB.Exec(createImageResultsTableSQL)
|
||||||
|
if createImageResultsTableErr != nil {
|
||||||
|
panic("Could not create image results table.")
|
||||||
|
}
|
||||||
|
|
||||||
|
createPostsResultsTableSQL := `
|
||||||
|
create table if not exists PostResults(
|
||||||
|
Id int primary key not null auto_increment,
|
||||||
|
SlowtwitchId int not null,
|
||||||
|
WordpressId int not null,
|
||||||
|
OldUrl nvarchar(500) not null,
|
||||||
|
OldUrlStatus int,
|
||||||
|
NewUrl nvarchar(500),
|
||||||
|
IsSuccess BIT not null,
|
||||||
|
ErrorMessage nvarchar(1500)
|
||||||
|
);`
|
||||||
|
_, createPostsResultsTableErr := resultsDB.Exec(createPostsResultsTableSQL)
|
||||||
|
if createPostsResultsTableErr != nil {
|
||||||
|
panic("Could not create post results table.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func migrateAuthors() {
|
func migrateAuthors() {
|
||||||
|
@ -243,7 +243,7 @@ func updatePostRelationships(postResults []PostResult, migration MigratePosts) {
|
|||||||
|
|
||||||
relatedSlowtwitchIds, slowtwitchIdsErr := slowtwitch.GetRelatedArticleIds(postResult.SlowtwitchId, migration.SlowtwitchDatabase)
|
relatedSlowtwitchIds, slowtwitchIdsErr := slowtwitch.GetRelatedArticleIds(postResult.SlowtwitchId, migration.SlowtwitchDatabase)
|
||||||
|
|
||||||
if slowtwitchIdsErr != nil {
|
if slowtwitchIdsErr != nil || len(relatedSlowtwitchIds) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, slowtwitchRelatedId := range relatedSlowtwitchIds {
|
for _, slowtwitchRelatedId := range relatedSlowtwitchIds {
|
||||||
@ -251,7 +251,7 @@ func updatePostRelationships(postResults []PostResult, migration MigratePosts) {
|
|||||||
if wordpressIdErr != nil {
|
if wordpressIdErr != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
relatedSlowtwitchIds = append(relatedWordpressIds, wordpressRelatedId)
|
relatedWordpressIds = append(relatedWordpressIds, wordpressRelatedId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(relatedWordpressIds) > 0 {
|
if len(relatedWordpressIds) > 0 {
|
||||||
|
@ -15,7 +15,7 @@ func GetRelatedArticleIds(postId int, db *sql.DB) ([]int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ids []int
|
var ids []int
|
||||||
idsAsStrings := strings.Split(spaceSeparatedIds, " ")
|
idsAsStrings := strings.Split(spaceSeparatedIds, "\r\n")
|
||||||
for _, stringId := range idsAsStrings {
|
for _, stringId := range idsAsStrings {
|
||||||
id, err := strconv.Atoi(stringId)
|
id, err := strconv.Atoi(stringId)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user