-
Notifications
You must be signed in to change notification settings - Fork 283
Support for custom schemas per database and custom extensions per schema #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom schemas per database and custom extensions per schema #147
Conversation
Resolves #146 and #140 Removes the top level configuration of schemas and extensions in the pillar and moved schemas under the scope of each individual db configuration. Now it is possible to use the same name for a schema in different databases. Extensions are configured as a list under each schema configuration. Now it is possible to install the same extension under multiple schemas in the same database and different databases. I updated the pillar.example to reflect the new structure.
@@ -34,6 +36,7 @@ postgres-reload-modules: | |||
# Tablespace states | |||
|
|||
{%- for name, tblspace in postgres.tablespaces|dictsort() %} | |||
{%- do tblspace.update({'name': name}) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required because I removed the automatic generation of name parameter from format_state
macro
@ek9 I took a shot at solving the per db extensions and schemas problem. I got it working on one instance of postgres in dev. I have not tried the |
I am having trouble getting the extensions to install on existing databases with this patch. |
@javierbertoli Are you free to review this, or recommend anyone else? |
@YetAnotherMinion I have tested PR successfully with one cavet. Regarding your comments ....
This is by design. Salt info messages report failure, but debug logging shows "
The following works on PG 9.6 and 10 with cavet (see below).
Cavet: SLS ID name collisions occur if an extension appears in more than one schema (same DB). Is this feature, or limitation, of your implementation???
Workaround: Commented out above to fix uuid-ossp name collision. Tested following schema....
OLD SOLUTION (working pillars)
|
@noelmcloughlin It is a mixture. On one hand it matches the behavior of Postgres exactly, where you cannot install an extension more than once per database. On the other hand, it should be possible to omit the schema attribute for an extension, which this PR fails to do. As written right now the end user would have to know the default schema name for each extension and add that to their pillar. See https://www.postgresql.org/docs/current/static/sql-createextension.html:
|
The primary feature of this PR is to enable this formula to be used with saltstack Nitrogen, see #146. |
Thanks @YetAnotherMinion I understand the intention now. This is not backwards compatible - but #146 needs to be fixed or formula breaks in Nitrogen.
Yes, the PG docs say that, on omitting the schema attribute, the current default object creation schema is used. Should a future PR address this possibility? If yes, consider raising as issue. |
To clarify what is needed from me to merge this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work here @YetAnotherMinion !
Unfortunately, this PR has been outdated and now is going to be superseded with #223 implementing both support for per-db schema and extensions with preserving backward compatibility.
@noelmcloughlin @aboe76 This could be closed now.
Thanks @YetAnotherMinion for the work on this. Cheers @vutny @aboe76 |
Resolves #146 and #140
Removes the top level configuration of schemas and extensions in the pillar and
moved schemas under the scope of each individual db configuration. Now it is
possible to use the same name for a schema in different databases. Extensions are
configured as a list under each schema configuration. Now it is possible to
install the same extension under multiple schemas in the same database and
different databases. I updated the pillar.example to reflect the new structure.