Skip to content
Update Database conversion authored by Émilie Pagé-Perron's avatar Émilie Pagé-Perron
......@@ -87,11 +87,12 @@ Select distinct cdli_db_old.revhistories.mod_date, cdli_db_old.revhistories.auth
```sql
UPDATE cdli_db.update_events
join cdli_db_tmp.authors_view on cdli_db_tmp.authors_view.mod_date = cdli_db.update_events.created
SET cdli_db.update_events.created_by =
(
SELECT author_id FROM cdli_db.authors
WHERE cdli_db_tmp.authors_view.mod_date = cdli_db.update_events.created
SELECT cdli_db.authors.id FROM cdli_db.authors
join cdli_db_tmp.authors_view on cdli_db_tmp.authors_view.author_id = cdli_db.authors.id
join cdli_db.update_events on cdli_db_tmp.authors_view.mod_date = cdli_db.update_events.created
WHERE cdli_db_tmp.authors_view.mod_date = cdli_db.update_events.created AND cdli_db.update_events.type = "atf"
LIMIT 1
);
```
......@@ -203,8 +204,6 @@ AND cdli_db_tmp.inscriptions_credits_view3.author_id_3 IS NOT NULL;
```
## 1.3 update inscriptions
I have overwritten this comment with an earlier version and lost the queries I used for this section :-( We will have to re-prepare them at the end to get ready for the second phase update.
## 1.3.1 Set is_latest"
match fulltrans.wholetext with inscriptions.atf if match, then is_latest =1, then fill other fields (transliteration, transliteration_clean,transliteration_for_search) I had used grouping for this to select the latest date in the group. https://stackoverflow.com/questions/12102200/get-records-with-max-value-for-each-group-of-grouped-sql-results
......@@ -212,7 +211,27 @@ match fulltrans.wholetext with inscriptions.atf if match, then is_latest =1, the
use the revhistories.id as inscriptions.id
get update_events_id by using revhistories.mod_date
use revhistories.new_text as inscriptions.atf & is_latest = 1
update the is_latest field and other atf fields
```sql
update cdli_db.inscriptions
join cdli_db_old.fulltrans on cdli_db_old.fulltrans.object_id = cdli_db.inscriptions.artifact_id
set
cdli_db.inscriptions.is_latest =1,
cdli_db.inscriptions.transliteration = cdli_db_old.fulltrans.transliteration
cdli_db.inscriptions.transliteration_clean = cdli_db_old.fulltrans.transliteration_clean
cdli_db.inscriptions.transliteration_for_search = cdli_db_old.fulltrans.transliteration_for_search
where
cdli_db_old.fulltrans.object_id = cdli_db.inscriptions.artifact_id
and
cdli_db_old.fulltrans.wholetext = cdli_db.inscriptions.atf
```
### 1.3.3 Set event update id in the inscription table
```sql
......
......