Lassen Sie uns zusätzliche Spalte Unterstützung füge ich eine Migration haben, machen wir es 001_Create_organization_users.php
mit zwei Spalten nennen, X, Y, dass sie beide eine zusammengesetzt PK:Wie Composite Primärschlüssel ändern
<?php
namespace Fuel\Migrations;
class Create_organizations_users
{
public function up()
{
\DBUtil::create_table('organizations_users', array(
'X' => array('constraint' => 11, 'type' => 'int'),
'Y' => array('constraint' => 11, 'type' => 'int')
), array('X', 'Y')); // Primary Key
}
// Other functions
}
Dann füge ich ein Spalte der Tabelle mit einer anderen Migration, nennt sie es 002_Add_column_to_organization_users.php
<?php
namespace Fuel\Migrations;
class Add_column_to_organization_users.php
{
public function up()
{
$fields = array(
'Z' => array(
'constraint' => 11, 'type' => 'int'),
);
\DBUtil::add_fields('organizations_users', $fields);
//....
}
kann ich bearbeiten irgendwie, dass die Migration, damit ich die Spalte ‚Z‘ als Primärschlüssel mit den zuvor eingegebenen Schlüsseln hinzufügen kann, so dass mein letzter Primärschlüssel ist X,Y,Z
?
Sie sagen, Sie müssen primär als 'X, Y, Z' anstelle von' X, Y' machen? – Ravi
@Ravi Ja, nachdem ich die Spalte 'Z' durch die zweite Migration hinzugefügt habe, muss ich das Feld als Teil des bereits vorhandenen Primärschlüssels hinzufügen. –