titleの統合
getty708 opened this issue · 3 comments
getty708 commented
目的
-
現在言語によってBibtexのタイトルを分けて登録している.(
title_en
,title_ja
) -
データ入力の際に言語の選択と食い違うことがあり,表示が崩れる原因となる.
-
primaryのタイトルと,secondaryのタイトルに 置き換える.
-
またこれに合わせて,モデルのタイポを修正する.
Todo
- Bibtexモデルに
title
,title_2nd_lang
を追加 - テンプレートの修正
-
title_en
,title_ja
の変更 - abstruct ==> abstract
注意
- この変更は破壊的な変更になるので,実行には注意が必要.
getty708 commented
初期ステップ
$ docker-compose exec django bash
root@django:/code# python manage.py makemigrations core
Migrations for 'core':
core/migrations/0008_auto_20200920_1157.py
- Add field title to bibtex
- Add field title_2nd_lang to bibtex
root@django:/code#
root@django:/code# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, sessions, users
Running migrations:
Applying core.0008_auto_20200920_1157... OK
データベースの更新 (フィールドのコピー)
-- primary title --
UPDATE `core_bibtex`
SET `core_bibtex`.`title` = `core_bibtex`.`title_en`
WHERE
`core_bibtex`.`language` = 'EN' ;
UPDATE `core_bibtex`
SET `core_bibtex`.`title` = `core_bibtex`.`title_ja`
WHERE
`core_bibtex`.`language` = 'JA' ;
-- 2nd title --
UPDATE `core_bibtex`
SET `core_bibtex`.`title_2nd_lang` = `core_bibtex`.`title_ja`
WHERE
`core_bibtex`.`language` = 'EN' ;
UPDATE `core_bibtex`
SET `core_bibtex`.`title_2nd_lang` = `core_bibtex`.`title_en`
WHERE
`core_bibtex`.`language` = 'JA' ;
abstractのフィールド名変更
root@django:/code# python manage.py makemigrations core
Did you rename bibtex.abstruct to bibtex.abstract (a TextField)? [y/N] y
Migrations for 'core':
core/migrations/0009_auto_20200920_2341.py
- Rename field abstruct on bibtex to abstract
- Alter field title_en on bibtex
- Alter field title_ja on bibtex
root@django:/code# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, sessions, users
Running migrations:
Applying core.0009_auto_20200920_2341... OK
getty708 commented
title_en, title_ja
フィールドの削除
root@django:/code# python manage.py makemigrations core
Migrations for 'core':
core/migrations/0010_auto_20200921_0017.py
- Alter unique_together for bibtex (1 constraint(s))
- Remove field title_en from bibtex
- Remove field title_ja from bibtex
root@django:/code# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, sessions, users
Running migrations:
Applying core.0010_auto_20200921_0017... OK
getty708 commented
実行コマンドメモ
Integrate Title feiled @ 2020.09.20
$ docker-compose exec django bash
root@django:/code# python manage.py makemigrations core
Migrations for 'core':
core/migrations/0008_auto_20200920_1157.py
- Add field title to bibtex
- Add field title_2nd_lang to bibtex
root@django:/code#
root@django:/code# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, sessions, users
Running migrations:
Applying core.0008_auto_20200920_1157... OK
-- prime lang --
UPDATE `core_bibtex`
SET `core_bibtex`.`title` = `core_bibtex`.`title_en`
WHERE
`core_bibtex`.`language` = 'EN' ;
UPDATE `core_bibtex`
SET `core_bibtex`.`title` = `core_bibtex`.`title_ja`
WHERE
`core_bibtex`.`language` = 'JA' ;
-- 2nd lang --
UPDATE `core_bibtex`
SET `core_bibtex`.`title_2nd_lang` = `core_bibtex`.`title_ja`
WHERE
`core_bibtex`.`language` = 'EN' ;
UPDATE `core_bibtex`
SET `core_bibtex`.`title_2nd_lang` = `core_bibtex`.`title_en`
WHERE
`core_bibtex`.`language` = 'JA' ;
root@django:/code# python manage.py makemigrations core
Did you rename bibtex.abstruct to bibtex.abstract (a TextField)? [y/N] y
Migrations for 'core':
core/migrations/0009_auto_20200920_2341.py
- Rename field abstruct on bibtex to abstract
- Alter field title_en on bibtex
- Alter field title_ja on bibtex
root@django:/code# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, sessions, users
Running migrations:
Applying core.0009_auto_20200920_2341... OK