You see, I have a language table with the following values:
Schema::create('idiomas', function (Blueprint $table) {
$table->increments('id');
$table->string('idioma');
$table->string('nivel_hablado');
$table->string('nivel_escrito');
$table->string('titulo_oficial');
$table->unsignedInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
The variable 'language' is what the language is (English, German, Japanese, etc) while 'user_id' is the user of the database. I want both variables to be primary, which will allow the user_id or the language to match in 2 rows, but there can never be 2 rows with exactly the same language and user_id. How do I achieve that?
Edit: I have already seen that my table already has a primary key, the id. The story is that I want both language and user_id to be unique, but not individually, but there can not be the same language for the same user, but a user can have several languages and one language can be in several users.
In MySQL it would be achieved like this:
CREATE TABLE idiomas(
id int PRIMARY KEY NOT NULL,
idioma varchar(25) NOT NULL,
user_id varchar(2) NOT NULL,
UNIQUE 'idioma_usuario_uidx' ('idioma','user_id'));