Results 1 to 10 of 18

Thread: Laravel Database Migrations

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    This is because you try to create database migration file with exactly same name as we have before. To find out which file you created, run

    Code:
    git status
    git diff
    Remove the file in app/database/migrations


    That is not in GIT (that is the one you created).
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  2. #2
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    How do I remove files from app/database/migrations ?

  3. #3
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    No, don't remove then. They are the database structure needed for application.

    When you run

    Code:
    php artisan migrate
    The command will look in that folder and read files one by one sorted by date and create database tables as required.

    Now the problem is, you added one extra file here, that is not needed. To find which one you added, post result of


    Code:
    git status
    and

    Code:
    git diff
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  4. #4
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    I run those commands, and got following results:

    Code:
    sherly@HOME:~/www/imagehostnow.com$ php artisan migrate
    **************************************
    *     Application In Production!     *
    **************************************
    
    Do you really wish to run this command? yes
    PHP Fatal error:  Cannot redeclare class CreateUsersTable in /home/sherly/www/imagehostnow.com/app/database/migrations/2015_01_14_052730_create_users_table.php on line 28
    Error in exception handler: The stream or file "/home/sherly/www/imagehostnow.com/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/sherly/www/imagehostnow.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84sherly@HOME:~/www/imagehostnow.com$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
        modified:   app/config/database.php
        modified:   app/storage/.gitignore
        modified:   app/storage/cache/.gitignore
        modified:   app/storage/logs/.gitignore
        modified:   app/storage/meta/.gitignore
        modified:   app/storage/sessions/.gitignore
        modified:   app/storage/views/.gitignore
        modified:   bootstrap/start.php
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
        app/config/database.php~
        app/database/migrations/2015_01_14_052420_create_users_table.php
        app/database/migrations/2015_01_14_052730_create_users_table.php
    
    no changes added to commit (use "git add" and/or "git commit -a")
    sherly@HOME:~/www/imagehostnow.com$ git diff
    diff --git a/app/config/database.php b/app/config/database.php
    index 3498fa8..27bd248 100644
    --- a/app/config/database.php
    +++ b/app/config/database.php
    @@ -55,9 +55,9 @@ return array(
                    'mysql' => array(
                            'driver'    => 'mysql',
                            'host'      => 'localhost',
    -                       'database'  => 'forge',
    -                       'username'  => 'forge',
    -                       'password'  => '',
    +                       'database'  => 'imagehostnow',
    +                       'username'  => 'root',
    +                       'password'  => 'flashwebhost',
                            'charset'   => 'utf8',
                            'collation' => 'utf8_unicode_ci',
                            'prefix'    => '',
    diff --git a/app/storage/.gitignore b/app/storage/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/cache/.gitignore b/app/storage/cache/.gitignore
    old mode 100644
    new mode 100755
    :...skipping...
    diff --git a/app/config/database.php b/app/config/database.php
    index 3498fa8..27bd248 100644
    --- a/app/config/database.php
    +++ b/app/config/database.php
    @@ -55,9 +55,9 @@ return array(
                    'mysql' => array(
                            'driver'    => 'mysql',
                            'host'      => 'localhost',
    -                       'database'  => 'forge',
    -                       'username'  => 'forge',
    -                       'password'  => '',
    +                       'database'  => 'imagehostnow',
    +                       'username'  => 'root',
    +                       'password'  => 'flashwebhost',
                            'charset'   => 'utf8',
                            'collation' => 'utf8_unicode_ci',
                            'prefix'    => '',
    diff --git a/app/storage/.gitignore b/app/storage/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/cache/.gitignore b/app/storage/cache/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/logs/.gitignore b/app/storage/logs/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/meta/.gitignore b/app/storage/meta/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/sessions/.gitignore b/app/storage/sessions/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/app/storage/views/.gitignore b/app/storage/views/.gitignore
    old mode 100644
    new mode 100755
    diff --git a/bootstrap/start.php b/bootstrap/start.php
    index 84559be..b6ecab2 100644
    --- a/bootstrap/start.php
    +++ b/bootstrap/start.php
    @@ -26,7 +26,7 @@ $app = new Illuminate\Foundation\Application;
     
     $env = $app->detectEnvironment(array(
     
    -       'local' => array('homestead'),
    +       'local' => array('homestead', 'sherlyf'),
     
     ));
     
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    sherly@HOME:~/www/imagehostnow.com$

  5. #5
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Look at result of git status command. You will see a section, that says "Untracked files", that list 3 files.

    Can you post name of that 3 files ?
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  6. #6
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    "Untracked files" names are:

    app/config/database.php~
    app/database/migrations/2015_01_14_052420_create_users_table.php
    app/database/migrations/2015_01_14_052730_create_users_table.php
    Last edited by sherlyk; 01-15-2015 at 06:26 AM.

  7. #7
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    These are files that you created (not yet committed to git).

    If you check gitlab, these files are not there.

    The file ending with ~ is created by gedit, don't use gedit, use sublime text for programing, we don't need our code base polluted by backup files like these.

    Other 2 files in migrations folder is created by "php artisan migrate:make" command.

    You can delete those 2 files, make sure you only delete the files (verify name) that listed as Untracked files.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •