Bahram Rostami
5 سال پیش توسط Bahram Rostami مطرح شد
11 پاسخ

اجرا نشدن migrate در CentOS 7

زمانی که میخوام migrate بزنم حتی اگر پروژه رو تازه ایجادم کرده باشم مشکل دارم
از تغییر دسترسی پوشه گرفته تا تغییر charset و collation خود دیتابیس.لاراول و تنظیم innoDB توی config/database.php لاراول ولی هنوز جواب نگرفتم نسخه های مختلفشم تست کردم ولی باز همین آش و همین کاسه هستش حتی توی ویندوزم تست میکنم مشکل همینه !!!!!!!!!!!!!
در ضمن dumpautoload و config:cache هم زدم ولی باز مشکل پا برجاست
نکته آخر اینکه اولین بار که migrate کنم میگه با موفقیت انجام شده و فقط دوتا جول ایجاد میشه user و migrations ولی وقتی status میگیرم زیر ran نوشته NO
یک دور صفر تا صد دوباره رفتم کدش رو پایین میزارم (توی این مورد فقط جدول migrations ایجاد میشه ولی اگر دستور رو به شکل php artisan migrat بزنم user م ایجاد میشه)
در ضمن اگر چندین migration غیر دیفالت سیستم ایجاد کنم به هیچ عنوان ایجاد نمیشه و فقط همین دو جدول ایجاد میشه
اگر کسی قبلا باهاش برخورد کرده ممنون میشم کمک کنه

[misterbr@dhcppc0 baran]$ php artisan migrate:status
No migrations found.
[misterbr@dhcppc0 baran]$ php artisan migrate:install
Migration table created successfully.
[misterbr@dhcppc0 baran]$ php artisan migrate:status
+------+------------------------------------------------+-------+
| Ran? | Migration                                      | Batch |
+------+------------------------------------------------+-------+
| No   | 2014_10_12_000000_create_users_table           |       |
| No   | 2014_10_12_100000_create_password_resets_table |       |
+------+------------------------------------------------+-------+
[misterbr@dhcppc0 baran]$ php artisan migrate:reset
Nothing to rollback.
[misterbr@dhcppc0 baran]$ php artisan migrate:install

   Illuminate\Database\QueryException  : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migrations' already exists (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB)

  at /var/www/html/baran/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migrations' already exists")
      /var/www/html/baran/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458

  2   PDOStatement::execute()
      /var/www/html/baran/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458

  Please use the argument -v to see more details.

ثبت پرسش جدید
رایموند
تخصص : مختصص وردپرس - برنامه نویس لار...
@Raymond 5 سال پیش مطرح شد
0

درود...
این دستور را امتحان کنید:

php artisan migrate:rollback

Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0
Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

البته الان دارم چک میکنم پیام خطای متفاوت رو براتون فرستادم
یه پیام خطای دیگه هم میده (که عموما اون رو همیهش بار اول میده) در مورد unique بودن email که باید اون رو میفرستادم براتون
فردا صبح اونم میفرستم
کلا منظور اینکه بعد اجرا migrate با اینکه موفقیت آمیز هستش ولی باز وقتی status میگیرم میگه ran نشده


محسن بستان
تخصص : Senior Backend Developer
@mohsenbostan 5 سال پیش مطرح شد
0

@bahram9000 این رو به migration تون اضافه کنید



use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('users');
        Schema::create('users', function (Blueprint $table) {
        // Your Table Here
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}```

محسن بستان
تخصص : Senior Backend Developer
@mohsenbostan 5 سال پیش مطرح شد
0

@mohsenbostan
Schema::dropIfExists('users');


Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

@mohsenbostan
کد های خودم دقیقا همینه، اما جواب نمیده
همیشه بار اول که میخواد نصب بشه پیام خطا پایین رو میده
خطایی که در اول سوال فرستادم بخاطر وجود جدول migrations بود (چون برای نشون دادن اینکه نصب انجام نمیشه فرستادم ببینید)
فقط لطفا کد ها رو دقت کنید
1- میگه موفق آمیز بوده نصب
2- استاتوس میگیرم میگه نصب نشده
3- (user,migrations )در صورتی که جداولش ایجاد شده
4- همون موقع میخوام rollback کنم میگه چیزی وجود ندار
5-پیام خطای در مورد یونیک بودن یا طول رشته و غیره میگه که همه رو توی migrate دستکاری کردم ولی باز ....
تقریبا سعی کردم تمامی دستورات رو به نوبت بزنم و خروجیش رو ببینید

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes. (SQL: alter table `users` add unique `users_email_unique`(`email`))

  at D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes.")
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  2   PDOStatement::execute()
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  Please use the argument -v to see more details.

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate:status
+------+------------------------------------------------+-------+
| Ran? | Migration                                      | Batch |
+------+------------------------------------------------+-------+
| No   | 2014_10_12_000000_create_users_table           |       |
| No   | 2014_10_12_100000_create_password_resets_table |       |
+------+------------------------------------------------+-------+

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate:rollback
Nothing to rollback.

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate:reset
Nothing to rollback.

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate:refresh
Nothing to rollback.
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes. (SQL: alter table `users` add unique `users_email_unique`(`email`))

  at D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes.")
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  2   PDOStatement::execute()
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  Please use the argument -v to see more details.

D:\Programming\WebSrv\xampp7\htdocs\baran>php artisan migrate:fresh
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes. (SQL: alter table `users` add unique `users_email_unique`(`email`))

  at D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes.")
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  2   PDOStatement::execute()
      D:\Programming\WebSrv\xampp7\htdocs\baran\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  Please use the argument -v to see more details.

Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

در ضمن
در نسخه CentOS و ویندوز نسخه php من 7.2 هستش


Alimotreb
تخصص : کانفیگ سرور و برنامه نویس
@Alimotreb 5 سال پیش مطرح شد
0

سلام
@bahram9000

فایل my.ini توی کانفیگ mysql
xampp رو باز کنید (xammp->mysql->my.ini)
مقادیر رو ویرایش کنید به حالت زیر

innodb_data_home_dir = "C:/xampp/mysql/data"
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = "C:/xampp/mysql/data"
#innodb_log_arch_dir = "C:/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
## Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

البته مسیر هارو هم دقت کنید برای من در درایو سی هست
این هارو عوض کنید یه ریستارت کنید
جدولاتون رو پاک کنید ، از اول مایگریت کنید


Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

سلام
همچی رو در my.ini وphp.ini مقادیرش رو سه برار کردم
ولی هیچ تغییری نکرده


Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

سلام خدمت دوستان عزیز، بلاخره مشکل حل شد
حالا بریم برای رفع عیب

اول توی بخش [mysql] توی مسیر mysql->my.ini (توی Xampp میشه آخرین خط این فایل) این و innodb_default_row_format=dynamic اضافه کنید، میشه شبیه کد زیر

[mysql]
default-character-set = utf8mb4
innodb_default_row_format=dynamic

اضافه کنید
بعد برید توی بخش config/database.php لاراول خودتون اینم توی بخش 'mysql' گزینه engine که برابر null هستش رو بگذارید برابر 'innodb row_format=dynamic' یعنی میشه مثل کد پایین، خط آخرش


        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => 'innodb row_format=dynamic',
        ],

ممنونم از دوستانی که مستقیم و غیر مستقیم کمک کردن
سپاس فراوان


Bahram Rostami
تخصص : توسعه دهنده و برنامه نویس
@bahram9000 5 سال پیش مطرح شد
0

و دوستانی که CentOS یا کلا Maria DB دارن
میتونن توی مسیر و فایل

app/Providers/AppServiceProvider.php

متد boot. این گزینه رو اضافه کنن Schema::defaultStringLength(191);
و یادتون نره که use Illuminate\Support\Facades\Schema; رو هم use کنید
یعنی میشه اینجوری

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

هم ویندوز و هم لینوکس م مشکلش حل شد D:


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام