DDC-114: Extend Drop Schema #1739

doctrinebot opened this Issue Nov 4, 2009 · 5 comments

2 participants


Jira issue originally created by user @beberlei:

Currently drop schema infers from the current metadata model which tables have to be dropped.

However when your schema changes and you then want to regenerate the database the tables may have changed and SQL errors like "table does not exist" may occur.

Therefore I propose to extend dropSchema() to have four modes:

  • "metadata" - Drop schema of the current metadata model.
  • "force-metadata" - Drop schema of the current metadata model, even if some tables don't exist.
  • "database" - Drop all tables of a database.
  • "orphans" - Drop all tables that are in the database but not in the metadata model.

Comment created by @beberlei:

Because of Bug DDC-98 the orphans command is a bit dangerous as of now, but the rest will be implemented for now. There are other problems also with orphans.


Comment created by @beberlei:

This is a bit more complicated because of foreign key constraints.

The algorithm for "database" should work like the following:

  1. Sort the Database Tables according to the Classes given by CommitOrderCalculator.
  2. List the tables of the database and append the additional tables to the stack.

Also force can be dropped by first retrieving a list of all the tables of a database and diff'ing the tables to be dropped.


Comment created by @beberlei:

Implemented a new mode "database" which drops all tables in the database, first the metadata tables based on commit order calculations, then the missing tables.

Additionally implemented a filter which deletes tables from the to drop list when they don't exist yet (which is relevant when metadata is changing alot).


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0-ALPHA3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment