Compare commits
No commits in common. "48ff48884b5ef7123c7bbed0975dc2ebda85cb17" and "e473c0e522ebc7ca92e7b0dbb96a63703279ffbf" have entirely different histories.
48ff48884b
...
e473c0e522
61
main.go
61
main.go
@ -42,67 +42,6 @@ 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 || len(relatedSlowtwitchIds) == 0 {
|
if slowtwitchIdsErr != nil {
|
||||||
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
|
||||||
}
|
}
|
||||||
relatedWordpressIds = append(relatedWordpressIds, wordpressRelatedId)
|
relatedSlowtwitchIds = 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, "\r\n")
|
idsAsStrings := strings.Split(spaceSeparatedIds, " ")
|
||||||
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