Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php artisan wink:migrate does nothing #8

Closed
javorszky opened this issue Nov 7, 2018 · 10 comments
Closed

php artisan wink:migrate does nothing #8

javorszky opened this issue Nov 7, 2018 · 10 comments

Comments

@javorszky
Copy link

As per instructions, running php artisan wink:migrate should give me default login credentials. However this is what happens for me:

21:14:55  javorszky@GaborrMBP  ~/Sites/wink  ⬡ v10.6.0  12s 
$ composer require writingink/wink
Using version ^0.0.1 for writingink/wink
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing writingink/wink (v0.0.1): Loading from cache
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: writingink/wink
Package manifest generated successfully.

 21:15:25  javorszky@GaborrMBP  ~/Sites/wink  ⬡ v10.6.0  14s 
$ php artisan wink:install
Publishing Wink Assets...
Publishing Wink Configuration...
Wink was installed successfully.

 21:15:35  javorszky@GaborrMBP  ~/Sites/wink  ⬡ v10.6.0 
$ php artisan wink:migrate
Nothing to migrate.

To further complicate things, I haven't set up a different database connection for wink, but decided to reuse the one laravel uses (because why not...)

@ghost
Copy link

ghost commented Nov 8, 2018

Having same issue here, but in my case I did a fresh install laravel project with database connection same as the current. Already doing some check. And I think the problem comes from here:

// wink/src/Console/MigrateCommand.php
$initialMigration = ! Schema::connection(config('wink.database_connection'))->hasTable('wink_posts');

...

if ($initialMigration) {
   WinkAuthor::create([
       ...
   ]);

   ...
}

So the default login credentials will not created if the wink_posts table already exist in your database. May be the condition for inital user, should determined by number of rows in wink_authors table and also maybe it will be good if there's a command to create new author.

@themsaid
Copy link
Owner

themsaid commented Nov 8, 2018

@ladhadha so in your case the tables are created by no initial user is created? The check shouldn't pass if the table doesn't exist.

@themsaid
Copy link
Owner

themsaid commented Nov 8, 2018

@javorszky can you share the entries in your migration table?

@ghost
Copy link

ghost commented Nov 8, 2018

@themsaid yes the tables was created. But theres no initial user create. The steps that I run was.

  • I install fresh laravel app,
  • I add writingink/wink as dependency,
  • I run php artisan migrate <-- I think this step that creating the tables, include wink_*
  • I run php artisan wink:install,
  • I run php artisan wink:migrate, the output was: Nothing to migrate.. Because I already run migration before.

Also I try to remove all, wink_* tables, and then run php artisan wink:migrate, but it gives me output:

Nothing to migrate.

   Illuminate\Database\QueryException  : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wink.wink_authors' doesn't exist (SQL: insert into `wink_authors` (`id`, `name`, `slug`, `bio`, `email`, `password`, `updated_at`, `created_at`) values (cf3c3e5f-0849-47af-bd1d-16fa946d9d16, Regina Phalange, regina-phalange, This is me., admin@mail.com, $2y$10$N0xME7bPmDPkYP58kFiwweypBwyTnyMLXwKoeXNJ4xPJbOpJk3hCy, 2018-11-08 08:43:59, 2018-11-08 08:43:59))

Migration not running and no table was created. Already inspecting why the migration, it's because the migration file: 2018_10_30_. I try to change the date to current date: Ex: 2018_11_08_, then it works. But I shouldn't rename the migration file name, right?

@javorszky
Copy link
Author

It only has the laravel ones, but the tables for wink exist.

screen shot 2018-11-08 at 08 48 46

I've done it again, here are steps to reproduce from nothing:

  1. laravel new wink2
  2. cd wink2
  3. composer require writingink/wink
  4. create empty database, and edit .env file so laravel can do its own migrations
  5. php artisan migrate, this migrates laravel tables
  6. php artisan wink:install
  7. add WINK_DB_CONNECTION to .env with the same value as DB_CONNECTION
  8. php artisan wink:migrate
  9. see "No migration needed"

Attached is a complete database dump

laravel.wink2-2018-11-08-08-44-db.sql.gz

@themsaid
Copy link
Owner

themsaid commented Nov 8, 2018

Guys you're running the installation steps wrong, don't run php artisan migrate but run php artisan wink:migrate

@themsaid themsaid closed this as completed Nov 8, 2018
@ghost
Copy link

ghost commented Nov 8, 2018

So for the fresh project, php artisan migrate should runned before adding writingink/wink as dependency, right? Or I just need to run php artisan wink:migrate at all?

@themsaid
Copy link
Owner

themsaid commented Nov 8, 2018

php artisan wink:migrate migrates wink tables and create an initial user. If you run the migrations before this command will not do anything since the tables already exist.

If you follow the installation steps as is it'll work .. composer require, wink:install, wink:migrate.

@javorszky
Copy link
Author

javorszky commented Nov 8, 2018

Right, but what the installation steps do not say is that the installation expects a base laravel to be up and running already.

ie these needed to have been run before doing the composer require:

  1. laravel new X
  2. set up creds
  3. php artisan migrate
  4. time passes
  5. composer require wink, etc...

@nateritter
Copy link

nateritter commented Nov 9, 2018

I just ran into this same issue and I agree with @javorszky ... docs need to be updated to remove any assumptions that laravel migrate needs to be run. That's not explicit (not implicit enough) in the current documentation to reduce confusion.

Including when to run the traditional laravel setup commands (and/or when not to) to be more explicit in the setup. That would help immensely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants