Closed wildtayne closed 7 years ago
Commenting only on shelter schema for now:
I suggest using CREATE SCHEMA IF NOT EXISTS
and remove DROP SCHEMA
in case the instructor has added to the schema previously. Shelter schema isn't really part of ClassDB, but is provided as a helpful starter. So, it is possible an instructor has extended. (Granted, CREATE TABLE
statements will remove any revisions to table schema.)
I don't see a need for ClassDB
to own the schema, because it is only an example schema. We do however need all the other privileges as granted to other app roles at the end of the script. At uninstall, we can leave the shelter schema as is, because creating that schema is not part of ClassDB installation.
I love the use of SET ROLE
, but it won't be needed if we agree ClassDB
won't own the schema.
I propose using SET LOCAL SCHEMA shelter
before creating tables and inserting rows and then remove the schema name qualification from object names. This way very few changes will be needed if an instructor wants to add the objects to a different schema, etc.
I propose renaming the files createShelterSchema.sql
and dropShelterSchema.sql
.
If it is not too much effort, I propose putting the INSERT
statements to a file such as populateShelter.sql
.
Thanks for the feedback. I think all of these changes make sense. Just to confirm how the scripts will behave:
SET LOCAL SCHEMA
and have unqualified table names.createShelterSchema
will create a schema called shelter, and create all the shelter tables. The schema and tables will be owned by the creating user - Students will have read access, and DBManager and Instructor will have read+write access. Currently, this script will require superuser permissions to be consistent with other ClassDB scripts, however in the future it would only need CREATE SCHEMA
.populateShelterSchema
will insert rows into the shelter tables. This can be run as any user with write permission on shelter.dropShelterSchema
will drop all tables in the shelter schema, along with the schema itself. This script must also be run as superuser.DROP OWNED BY
statements to removeClassDBFromServer
for Student and DBManager. These server the purpose of dropping the permissions on any extra schemas, like shelter, while keeping the schemas.I'll push a new commit in a minute that should address these changes.
This branch contains a few different changes:
Uninstaller:
removeClassDBFromServer.sql
expects shelter to have been dropped. Currently, users have to manually rundropShelter.sql
to do this.Shelter Schema:
SET ROLE ClassDB
when creating the tables, so they are all owned by classdb. If this is not optimal, I can change to using ALTER TABLE statements.Misc:
perpareClassServer.sql
to superuser, which fixes #74.Two further questions: