Found my own answer. Turns out the db_schema.xml file generated automatically by Magento had an error. The line that declares the name of the table was missing the resource value.
This is how the tag was generated after running the CLI command:
<table name="my_table_name" resource="" engine="innodb" comment="My Table Comment">
And this is how it should be:
<table name="my_table_name" resource="default" engine="innodb" comment="My Table Comment">
resource should contain the database shard on which to install the table. This value must be default, quote, or sales. In my case, adding default did the trick.
Edit (04/25/2019):
Whenever the db_whitelist_schema.json file is not created automatically when running the bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Modulename command you can safely assume there’s an error in the etc/db_schema.xml file of your module.
Since the terminal won’t return an error msg to help you fix the issue, you can resort to the following hack to discover the missing piece in your db_schema file.
1) Open the following core file: vendor/magento/framework/Setup/Declaration/Schema/SchemaConfig.php
2) Locate the getDeclarationConfig() method and add a try-catch like this:
/**
* @inheritdoc
*/
public function getDeclarationConfig()
{
try {
$schema = $this->schemaFactory->create();
$data = $this->readerComposite->read(FileResolverByModule::ALL_MODULES);
$this->declarativeSchemaBuilder->addTablesData($data['table']);
$schema = $this->declarativeSchemaBuilder->build($schema);
return $schema;
} catch (\Exception $e) {
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/schema.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info($e->getMessage());
}
}
3) Now run the bin/magento setup:db-declaration:generate-whitelist
4) Check for any errors in var/log/schema.log
5) Rinse and repeat until you fix all the errors in your db_schema.xml file
6) Don’t forget to remove the temporary changes you made to the core file!
db_schema.xmlsometimes are not generated. Recent versions (M2.3.5) seems to have slightly better error reporting when trying to generate whitelist, (unique keys)... but not everything reports immediately. – CvRChameleon Aug 16 '21 at 08:35