Pass a base relation to build_default_scope when joining

This allows the default scope to be built using the current table alias.
Resolves #12770
Merge pull request #14154 from al2o3cr/issue12770

Pass a base relation to build_default_scope when joining
PostgreSQL, test cases to lock the current column types.
Fix warning for overshadowing XML variable
Merge pull request #14515 from mzahir/fix_xml_warning

Fix warning for overshadowing XML variable
PostgreSQL, test-cases to lock down column default values.
Refactor test to use DdlHelper.

Follow-Up to https://github.com/rails/rails/pull/14400

This ensures that all tables are removed after each test and thereby
allowing us to run the tests in a random order.