dwyl / mvp

šŸ“² simplest version of the @dwyl app
https://mvp.fly.dev
GNU General Public License v2.0
87 stars 2 forks source link

Chore: Rename `timer.end` to `timer.stop` #114

Closed nelsonic closed 2 years ago

nelsonic commented 2 years ago

At present the timer schema has an end field: šŸ”š https://github.com/dwyl/app-mvp-phoenix/blob/bf65127b434c5861e56a501a6350978c142df788/lib/app/timer.ex#L10

This is a remnant from the previous MVP (JavaScript) where we selected end thinking it was a good field name. But in Elixir, end is a "reserved" keyword for ending functions, conditionals and loops ... šŸ™„ The MVP is working ... https://github.com/dwyl/app-mvp-phoenix/issues/89#issuecomment-1190240856 But as I'm updating the README.md I'm spotting things I want to improve. This is definitely one of them that we can "fix" reasonably easily now. šŸ¤ž

Todo

This might take a while because there are many instances ... ā³ But I really want to avoid any unnecessary head-scratchers for other people reading the README.md in the future. šŸ’­

nelsonic commented 2 years ago

It's just occurred to me: I can make these changes in the localhost reasonably easily. šŸ’­ But then the App that has been deployed to Fly.io mvp.fly.dev would require a migration ... šŸ™„ I'm tempted to just do it manually in the PostgreSQL CLI ... šŸ§‘ā€šŸ’»

nelsonic commented 2 years ago

https://fly.io/docs/flyctl/postgres-connect/

nelsonic commented 2 years ago

Updated ERD:

image
nelsonic commented 2 years ago
flyctl postgres connect -a mvp-db
Connecting to mvp-db.internal... complete
psql (14.4 (Debian 14.4-1.pgdg110+1))
Type "help" for help.

describe tables (\dt):

postgres-# \c mvp
You are now connected to database "mvp" as user "postgres".
mvp-# \dt
 public | items             | table | mvp
 public | people            | table | mvp
 public | schema_migrations | table | mvp
 public | timers            | table | mvp

rename:

ALTER TABLE timers RENAME COLUMN "end" TO "stop";

Confirm:

SELECT 
   table_name, 
   column_name, 
   data_type 
FROM 
   information_schema.columns
WHERE 
   table_name = 'timers';
table_name column_name data_type
timers id bigint
timers start timestamp without time zone
timers stop timestamp without time zone
timers item_id bigint
timers person_id bigint
timers inserted_at timestamp without time zone
timers updated_at timestamp without time zone

Looks good. Now need to redeploy the app with the updated code. šŸ¤ž

nelsonic commented 2 years ago

Looks like everything still works: šŸ‘Œ

image

Thank goodness for tests. šŸŽ‰