Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions database/migrations/add_unique_position_constraint.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Before running this migration, ensure you have no duplicate
* positions in your table by running:
*
* php artisan flowforge:repair-positions YourModel --column=status
*/
public function up(): void
{
Schema::table('your_table_name', function (Blueprint $table) {
// Add unique constraint on (status_column, position_column) combination
// This prevents duplicate positions within the same column/status
$table->unique(['status_column', 'position_column'], 'unique_position_per_column');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('your_table_name', function (Blueprint $table) {
$table->dropUnique('unique_position_per_column');
});
}
};
2 changes: 1 addition & 1 deletion resources/dist/flowforge.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/js/flowforge.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function flowforge({state}) {
const afterCardId = cardIndex > 0 ? newOrder[cardIndex - 1] : null;
const beforeCardId = cardIndex < newOrder.length - 1 ? newOrder[cardIndex + 1] : null;

this.$wire.moveCard(cardId, targetColumn, beforeCardId, afterCardId)
this.$wire.moveCard(cardId, targetColumn, afterCardId, beforeCardId)
.then(() => this.setCardState(cardElement, false))
.catch(() => this.setCardState(cardElement, false));
},
Expand Down
Loading