You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are time when code that manipulates or even fetches data from some DataObject could be run during or before dev/build. For those situations, we need to confirm that the relevant table(s) exist in the database, and that all of the necessary database columns exist in those tables.
Currently in those situations we have a variety of different solutions. Max identified some of these in silverstripe/silverstripe-graphql#445 (comment) which I have included in a list further down in this description. We should have a unified way of performing these checks.
Reasons to making these checks unified:
Easier maintenance
if we identify a problem with the way the checks are being made we just have to fix it in one place
if we need to add additional checks, we can just add those checks in the unified method
Provides a clear API for developers who need to do the same checks in their own projects.
Ways these checks are currently being performed
These have been found using github search, which I have noticed misses stuff sometimes, so this may not be a complete list. This does not include anything included inside tests or test classes.
Caches the ready state if it is indeed ready (so future calls in the same request for classes we know are ready don't have to query the db again)
Skips TestOnly classes
Checks the entire hierarchy of a class (so confirms that all superclasses have their tables/columns, and checks the same for subclasses, which may ultimately be injected to replace the class we'd normally expect)
Checks if the classes which should have tables do have tables
Checks if the those tables have all columns they should have (including those provided by Extension classes)
Only checks if the given class has fields in its own table - this means subclasses which don't have their own db fields will return false for this even if the database is ready for fetching or manipulating data for that class.
Doesn't check if the table has all the columns it should have
There are time when code that manipulates or even fetches data from some
DataObject
could be run during or before dev/build. For those situations, we need to confirm that the relevant table(s) exist in the database, and that all of the necessary database columns exist in those tables.Currently in those situations we have a variety of different solutions. Max identified some of these in silverstripe/silverstripe-graphql#445 (comment) which I have included in a list further down in this description. We should have a unified way of performing these checks.
Reasons to making these checks unified:
--no-database
schema build fails with various module configuration silverstripe-graphql#445)Ways these checks are currently being performed
These have been found using github search, which I have noticed misses stuff sometimes, so this may not be a complete list. This does not include anything included inside tests or test classes.
Security::database_is_ready()
TestOnly
classesExtension
classes)Member
if the db isn't ready for thatDataObjectSchema::classHasTable()
false
for this even if the database is ready for fetching or manipulating data for that class.SiteConfig
table exists before querying it - the method which calls this then separately confirms if all the relevant columns are present, though extensions may not have been applied by this point.ClassInfo::hasTable()
DBSchemaManager::hasTable()
ModelForController
.Security::database_is_ready()
checkDBSchemaManager::hasTable()
SiteConfig
defaults in TranslatableAcceptance Criteria
Extension
to aDataObject
after the first dev/buildDataObject
after the first dev/build$table_name
config for aDataObject
after the first dev/buildPRs
The text was updated successfully, but these errors were encountered: