mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

Issues with running (updating) schema.sql file #493

Closed baron-zeng closed 7 months ago

baron-zeng commented 7 months ago

Hello,

After updating my schema.sql file in the pg_normalized_batch, I cannot execute the file.

Currently, I am running this command

docker-compose exec pg_normalized_batch psql -U postgres -d postgres -f services/pg_normalized_batch/schema.sql

And getting this error

psql:services/pg_normalized_batch/schema.sql:1: ERROR:  extension "postgis" already exists
BEGIN
psql:services/pg_normalized_batch/schema.sql:28: ERROR:  relation "users" already exists

Should I have made my updates to the schema.sql directly in psql? Or is there a way to execute my schema.sql as it is (I made the changes in VIM)?

mikeizbicki commented 7 months ago

You're correct to make the changes directly to the schema.sql file. The way you are loading that into postgres, however, is incorrect. The Dockerfile specifies how to load the schema into the database. Therefore, when you modify the schema.sql file, you need to rebuild the image. In order for the newly built image to create a new database, you'll also need to delete the existing volume.