-
Notifications
You must be signed in to change notification settings - Fork 588
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
Backticks around index names are MySQL specific #17
Comments
The reason for adding that was, if the name contained a space, it failed. I guess I should first check if it contains a space and then add standard quotes. Will take a look at this as soon as I get a moment. |
I think the better approach might be to (1) detect if the connection is MySQL, and only then use backticks, and (2) replace spaces with underscores for the index name. I ended up just manually editing all my initial migrations, so this isn't a blocker issue for me, but it was a bit surprising that the migrations that were generated were causing errors from the start. Overall though, your code still saved me a ton of work and many hours, so cheers for that! 👍 |
Is this MySQL specific? I don't think backticks can be used in names there either. I would say it's probably safest/best to remove them for all indices (or names in general) and disallow or replace spaces. |
@joboscribe They are not being used IN names, they are being used to surround names (quote them). And yes, the backtick character is used by MySQL for this in all areas - tables names, column names, etc. |
@vlucas i'm seeing the following error:
From the line:
Which makes sense given this from
Since Very nice tool, though, saved me a lot of hours of hand-crafting my own migrations. Migrations that would have been terribly, horribly broken. |
@joboscribe Ah, I see. It seems that there is a larger issue here than I even first thought. |
After reverse engineering a mysql schema, once I remove the backticks, all On Wed, Jul 23, 2014 at 1:37 PM, Vance Lucas notifications@github.com
|
The idea behind this is to "recreate" the database already present. So, if the database was created in MySQL with conflicting table names, the migrations should look the same. However, something I've been wanting to add, is a option to "ignoreIndexNames" and "ignoreForeignKeyNames". That way, they will be blank, and Laravel will use its defaults. This could be useful if you are trying to update your existing database, using Laravel's default db conventions. However, in most cases, I assume the user would want an identical representation of their database. |
I think that's a reasonable assumption. I agree if you're forward On Sun, Jul 27, 2014 at 5:36 AM, Bernhard Breytenbach <
|
Added --defaultIndexNames and --defaultFKNames |
The generated migrations have backticks in the index names, like this:
These cause errors in PostgreSQL, as the backtick character is not ANSI SQL, and is specific to MySQL only.
Error text in console from Artisan:
Index names without the backticks works fine, however:
The text was updated successfully, but these errors were encountered: