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

Add interface wrapper for CREATE IF NOT EXISTS #38

Open
SchaichAlonso opened this issue Oct 20, 2023 · 2 comments
Open

Add interface wrapper for CREATE IF NOT EXISTS #38

SchaichAlonso opened this issue Oct 20, 2023 · 2 comments
Labels
enhancement New feature or request future Task that has lower priority because there is still much to do. schema builder Schema builder

Comments

@SchaichAlonso
Copy link
Contributor

There is dropIfExists for tables but there is no wrapper for CREATE TABLE IF NOT EXISTS.

Likewise, the querybuilder doesn't interface CREATE INDEX IF NOT EXISTS .

@silverqx silverqx added the enhancement New feature or request label Oct 21, 2023
@silverqx
Copy link
Owner

I will not add this at sure.

Currently, there is Schema::hasTable().

For indexes, I will not add something like indexIfNotExists() or fullTextIfNotExists() why would you do that in migrations? The current API for indexes is here, which I think is good enough for now.

I understand why you want it, in testing things around it can make sense for you, but if you look at it from the perspective of creating migrations then there is no reason for that. Why would you call indexIfNotExists() in migrations up/down?

@SchaichAlonso
Copy link
Contributor Author

SchaichAlonso commented Oct 21, 2023

For being consistently ... lazy.

No way being lazy with 72920 LoC and 4190 commits 😎🔥

If there's no legitimate use case for CREATE IF NOT EXISTS, then there is no legitimate use case for DROP IF EXISTS either, yet drop has a wrapper, and create does not.

This is not true, I worked on a few bigger projects (~50 migration classes), and believe me, you will need dropIfNotExists() in the first down migration but will never need indexCreateIfNotExists() because you must always drop things (tables, columns, indexes) if you are migrating down and they are already dropped if you are migrating up again.

You can still write your DDL query manually using the DB::statement() or DB::unprepared() if you need more specialized SQL query even in the migration classes.

Not every SQL statement needs to have a query/schema builder wrapper.

But we can leave this open it can be implemented in the future especially createIfNotExists() for tables.

@silverqx silverqx added future Task that has lower priority because there is still much to do. schema builder Schema builder labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request future Task that has lower priority because there is still much to do. schema builder Schema builder
Projects
None yet
Development

No branches or pull requests

2 participants