Migration table schema #895
-
How can I change the default schema of "migration" table? In our application dont have access to public schema and when I run "piccolo migrations forwards" it gives "asyncpg.exceptions.InsufficientPrivilegeError: permission denied for schema public" |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
It's a good point - currently migrations assume the default schema is being used. I'll have to add this as a new feature. Probably allowing the user to specify it in In the mean time, the solutions are: Modify your local copy of PiccoloChange this line: To this instead: class Migration(Table, schema="my_schema"): Copy the migrations app into your projectCopy this entire folder into your project: https://github.com/piccolo-orm/piccolo/tree/master/piccolo/apps/migrations You might have to change this line to something like 'my_migrations': And then register this new app in |
Beta Was this translation helpful? Give feedback.
-
@dantownsend from piccolo.apps.migrations import tables
from myapp import config
class Migration(tables.Migration, schema=config.MY_SCHEMA):
pass
tables.Migration = Migration Would this solution correctly override the schema of the migrations table by replacing the original Migrations table with a custom one which has its schema explicitly defined from a configuration constant? This solution would not require pulling piccolo source code into user projects, so its cleaner. |
Beta Was this translation helpful? Give feedback.
It's a good point - currently migrations assume the default schema is being used.
I'll have to add this as a new feature. Probably allowing the user to specify it in
piccolo_conf.py
.In the mean time, the solutions are:
Modify your local copy of Piccolo
Change this line:
https://github.com/piccolo-orm/piccolo/blob/28fe3a4fe3266d17c7a37406dc7fdbd92223d5f6/piccolo/apps/migrations/tables.py#L10C1-L10C24
To this instead:
Copy the migrations app into your project
Copy this entire folder into your project:
https://github.com/piccolo-orm/piccolo/tree/master/piccolo/apps/migrations
You might have to change this line to something like 'my_migrations':
p…