Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could we drop a table without using its class? #166

Closed
mengdd opened this issue Jan 25, 2019 · 1 comment
Closed

How could we drop a table without using its class? #166

mengdd opened this issue Jan 25, 2019 · 1 comment

Comments

@mengdd
Copy link

mengdd commented Jan 25, 2019

I have this need to drop a table I no longer use.
I want to delete all related codes including the class file.
Also I want to drop this table from db during migration because the table might be existed in old versions.

I thought it could be done if I drop using the table name, but I only found these two APIs available to drop a table:

public static <T, ID> int dropTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig, boolean ignoreErrors)

public static <T, ID> int dropTable(ConnectionSource connectionSource, Class<T> dataClass, boolean ignoreErrors)

DatabaseTableConfig also need a class object in its constructor.

So I have to provide the class which declare the table.

Now I have two choices:

  • Delete the class and let the table left alone in app upgraded from old versions.
  • Keep the class and drop table. -> the codebase will look strange to keep these codes.

How could I delete the class and drop the table?

@j256
Copy link
Owner

j256 commented Nov 16, 2020

You could always issue the command using raw methods. You can always create a fake class with the matching table name to drop it. I considered adding a dropTable(String) method but the issue is that if you created indexes, they wouldn't be removed. Given that you don't do a createTable(String), having a drop table string seems like bad parity.

@j256 j256 closed this as completed Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants