copetit / whereareyou

for our family
1 stars 1 forks source link

db-change-mongo-to-mysql #5 #6

Closed shhwan closed 3 years ago

shhwan commented 3 years ago

MongoDB -> MysqlDB

Docker Compose up

docker-compose up -d

Check DB


$ docker exec -it mysql-wau bash
$ mysql -u root -p
mysql> use wau
mysql> show tables;
+---------------+
| Tables_in_wau |
+---------------+
| contents      |
| location_info |
| posting       |
| user          |
+---------------+
mysql> SHOW COLUMNS FROM user;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int          | NO   | PRI | NULL    | auto_increment |
| Password     | varchar(255) | NO   |     | NULL    |                |
| MailAddress  | varchar(255) | NO   |     | NULL    |                |
| postingNumId | int          | YES  | UNI | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
shhwan commented 3 years ago

確認ありがとうございます。 以下修正しました。

mysql> select * from user; +----+----------+------------------+-----------+ | id | Password | MailAddress | postingId | +----+----------+------------------+-----------+ | 1 | 1234 | hoge@example.com | 1 | | 2 | 1234 | hoge@example.com | 2 | +----+----------+------------------+-----------+ 2 rows in set (0.00 sec)

mysql> select * from location_info; +----+-----+-----+-----------+ | id | lat | lng | postingId | +----+-----+-----+-----------+ | 1 | 123 | 456 | 1 | | 2 | 123 | 456 | 2 | +----+-----+-----+-----------+ 2 rows in set (0.01 sec)

mysql> select * from contents; +----+----------------+----------------+-----------+ | id | imageUrl | videoUrl | postingId | +----+----------------+----------------+-----------+ | 1 | dummyImage.com | dummyVideo.com | 1 | | 2 | dummyImage.com | dummyVideo.com | 2 | +----+----------------+----------------+-----------+ 2 rows in set (0.00 sec)


contentsのimageUrl/videoUrlはAPIの方進みながら修正します。
posting tableのIDをForeign Keyとして他のテーブルではpostingIdでrelationをとってます。
shhwan commented 3 years ago

あと、https://github.com/copetit/whereareyou/pull/6#pullrequestreview-793669446 これのすぐ反映されないところですが npm run startになっていたため、start:devに変えました。 https://github.com/copetit/whereareyou/pull/6/commits/dfeb60f48836e2cff0be96d90989379e8832eb28

これで、コンテナもWatchモードになるため、修正がすぐ反映されます。