Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

577
Views
No se puede crear o cambiar una tabla sin una clave principal - Laravel DigitalOcean Managed Database

Acabo de implementar mi aplicación en DigitalOcean usando (Base de datos administrada) y recibo el siguiente error cuando llamo a php artisan migrate

SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. (SQL: create table `sessions` (`id` varchar(255) not null, `user_id` bigint unsigned null, `ip_address` varchar(45) null, `user_agent` text null, `payload` text not null, `last_activity` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Parece que Laravel Migrations no funciona cuando mysql var sql_require_primary_key se establece en verdadero.

¿Tienes alguna solución para eso?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Estaba tratando de solucionar este problema con una importación a DO Managed MySQL usando un archivo mysqldump desde una instalación de WordPress. Descubrí que agregar esto en la parte superior del archivo funcionó para mi importación.

 SET @ORIG_SQL_REQUIRE_PRIMARY_KEY = @@SQL_REQUIRE_PRIMARY_KEY; SET SQL_REQUIRE_PRIMARY_KEY = 0;

Luego importé usando JetBrains DataGrip y funcionó sin errores.

over 4 years ago · Santiago Trujillo Report

0

Simplemente agregue set sql_require_primary_key = off Me gusta esto

Haga clic para ver la imagen

a su archivo SQL.

over 4 years ago · Santiago Trujillo Report

0

Agregue su primera migración:

 \Illuminate\Support\Facades\DB::statement('SET SESSION sql_require_primary_key=0');

Interior: Función Schema::create() .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!