We want to be able to have tables in different schemas, currently Django does not support multiple schemas and issues the SQL statement without schema, e.g. select a,b from t. Therefore the schema is the default doc.
The schema should be settable at settings level and meta level. So there can be a global schema for everything and specific schemas for some models, for situations where the user want to access other schemas.
settings
DATABASES = {
"default": {
"ENGINE": "cratedb_django",
"SERVERS": ["192.168.88.251:4200"],
"GLOBAL_SCHEMA": "someschema"
}
}
model
class SomeModel(CrateDBModel):
...
class Meta:
schema = 'metrics'
In this situation, migrations would run in someschema but queries on SomeModel would run on metrics.
Schema definition priority goes as follows:
- locally defined (Model)
- settings defined (Settings)
By default GLOBAL_SCHEMA will be doc. If the model does not implement schema, GLOBAL_SCHEMA is used.
Open questions
How would this behave in different databases setup?
We want to be able to have tables in different schemas, currently Django does not support multiple schemas and issues the SQL statement without schema, e.g.
select a,b from t. Therefore the schema is the defaultdoc.The schema should be settable at
settingslevel andmetalevel. So there can be a global schema for everything and specific schemas for some models, for situations where the user want to access other schemas.settings
model
In this situation, migrations would run in
someschemabut queries onSomeModelwould run onmetrics.Schema definition priority goes as follows:
By default
GLOBAL_SCHEMAwill bedoc. If the model does not implementschema,GLOBAL_SCHEMAis used.Open questions
How would this behave in different databases setup?