Good, I'm introducing myself a bit in Laravel and I'm passing a code that I have in pdo, I'm with the creation of tables and tells me this error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near'
num_documento('titulo_documento'
)' at line 1 (SQL: alter table 'documentos' add primary key
'acronimo_proye
cto' using num_documento('titulo_documento'))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MariaDB
server version for the right syntax to use near num_documento('titulo_documento')' at line 1
And this is my code
public function up()
{
Schema::create('documentos', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->string('titulo_documento', 50);
$table->char('acronimo_proyecto', 3);
$table->string('estado', 10);
$table->string('idioma', 10);
$table->char('num_documento', 2);
$table->char('version', 1);
$table->char('revision', 1);
$table->text('descripcion');
$table->date('fecha');
$table->char('confidencialidad', 1);
$table->char('acronimo_documento', 4);
$table->char('acronimo_subcategorias', 3);
$table->char('acronimo_usuario', 4);
$table->char('aprobado', 4);
$table->char('autorizado', 4);
$table->char('revisor', 4);
$table->char('acronimo_empresa', 3);
$table->string('codigo_proyecto', 30);
$table->primary('titulo_documento','acronimo_proyecto','num_documento','version','revision','codigo_proyecto');
$table->foreign('acronimo_subcategorias','acronimo_proyecto')->references('acronimo_subcategorias','acronimo_proyecto')->on('tipo_de_documentos')->onDelete('cascade');
$table->foreign('acronimo_usuario')->references('acronimo_usuario')->on('usuarios')->onDelete('cascade');
$table->foreign('aprobado')->references('acronimo_usuario')->on('usuarios')->onDelete('cascade');
$table->foreign('autorizado')->references('acronimo_usuario')->on('usuarios')->onDelete('cascade');
$table->foreign('revisor')->references('acronimo_usuario')->on('usuarios')->onDelete('cascade');
$table->foreign('acronimo_empresa')->references('acronimo')->on('companias')->onDelete('cascade');
$table->foreign('acronimo_proyecto')->references('acronimo_proyecto')->on('proyectos')->onDelete('cascade');
});
}
In the foreign I do not believe to have any error, but until not solving the one of the PK I will not be able to continue reviewing the FK, but even so the error comes from the construction of the primary. Thanks to everyone.