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

Wrong unique index from migration #709

Closed
jirapetr opened this issue Apr 19, 2022 · 5 comments
Closed

Wrong unique index from migration #709

jirapetr opened this issue Apr 19, 2022 · 5 comments

Comments

@jirapetr
Copy link

Wrong unique index

this update
#600
46e6f7b
made unique index with lower() PHP function in migration laravel script
for example: create unique index card_types_id_card_type_uk on card_types (lower(id_card_type))
problem:
if I want add make foring key to this master table/colum (id_card_type)
it emit error: that no primary kye or unique index exist

Code snippet of problem

public function compileUnique(Blueprint $blueprint, Fluent $command)
{
$columns = array_map(function ($column) {
$column = $this->wrap($column);
return "lower({$column})";
}, $command->columns);

    $columns = implode(', ', $columns);

    return sprintf('create unique index %s on %s (%s)', $command->index, $this->wrapTable($blueprint), $columns);
}

Please remove lower function in compileUnique()

System details

  • Linux
  • PHP 8n
  • Laravel Version 8
  • Laravel-OCI8 Version: 8
@yajra
Copy link
Owner

yajra commented May 21, 2022

Can you please provide a working script to replicates the issue?

@jirapetr
Copy link
Author

jirapetr commented May 21, 2022

On Laravel migration script:
TABLE MASTER:
$table->unsignedBigInteger('id_card_type')->unique();

TABLE SLAVE:
$table->foreign('id_card_type')->references('id_card_type')->on('table_master')->onDelete('CASCADE');
// this emit error: that no primary kye or unique index exist

@jirapetr
Copy link
Author

migration, resp. function compileUnique it should use "lower()" function only for var/text type of DB colums (not for int)

@github-actions
Copy link

github-actions bot commented Oct 7, 2022

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 7, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants