Skip to content

Commit 8288d2d

Browse files
committed
fix: order of extracted column
1 parent 167372c commit 8288d2d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/CustomMySqlQueries.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function getAllColumnsInTable(string $tableName): Collection
4949
return DB::table('INFORMATION_SCHEMA.COLUMNS')
5050
->where('TABLE_SCHEMA', config('database.connections.mysql.database'))
5151
->where('TABLE_NAME', $tableName)
52+
->orderBy('ORDINAL_POSITION')
5253
->get();
5354
}
5455

@@ -63,6 +64,7 @@ public function extractForeignKeys(string $tableName): Collection
6364
->where('TABLE_SCHEMA', config('database.connections.mysql.database'))
6465
->where('TABLE_NAME', $tableName)
6566
->whereNotNull('REFERENCED_TABLE_NAME')
67+
->orderBy('ORDINAL_POSITION')
6668
->get();
6769

6870
$foreignKeys->each(function ($foreignKey) {
@@ -72,4 +74,4 @@ public function extractForeignKeys(string $tableName): Collection
7274

7375
return $foreignKeys;
7476
}
75-
}
77+
}

0 commit comments

Comments
 (0)