I would like some help with seeding my database, using Laravel Forge.
I've carried out the deployment for my application and it was successful. The tables were created, as my latest deployment log shows:
From github.com:nahin14/cin-app
* branch master -> FETCH_HEAD
Already up-to-date.
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating autoload files
Generating optimized class loader
Compiling common classes
Migrated: 2014_10_11_000000_create_roles_table
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrated: 2015_04_16_205049_create_statuses_table
Migrated: 2015_04_16_205103_create_claim_types_table
Migrated: 2015_04_16_205118_create_insurance_types_table
Migrated: 2015_04_16_205127_create_insurers_table
Migrated: 2015_04_16_205215_create_solicitors_table
Migrated: 2015_04_16_205224_create_client_types_table
Migrated: 2015_04_16_205229_create_clients_table
Migrated: 2015_04_16_205243_create_vehicle_types_table
Migrated: 2015_04_16_205251_create_vehicles_table
Migrated: 2015_04_16_205312_create_claims_table
Migrated: 2015_04_16_205318_create_tasks_table
However i would like to know how i can seed the tables. I have a databaseseeder.php file set up with all the seeding information.
So, how would i go about seeding the tables with the seeding information from the databaseseeder.php file.
Thank you.
There is a force for production, similar as on the migrate command:
php artisan db:seed --force
But for shure, take care with this...
You can look at the options of every artisan command with the help command, ex
php artisan help db:seed
php artisan db:seed
or
php artisan db:seed --class="TheOneSeeder"
Make sure the value for APP_ENV in your environment settings (.env file) is set to something other than production - staging, local, etc ...
You can navigate to this by going to Sites->Your Site->Environment->Edit Environment.
For the deploy script:
php artisan db:seed --class=TheOneSeeder
Worked for me.
Related
when i write this command:
php artisan migrate
Laravel Provides Database migrations which don't work very well for me when i write this command:
php artisan migrate
it always give me this error
Change the .env file from 127.0.0.1 to localhost fixed it.
DB_HOST=localhost
do config:cache after .env file change. php artisan config:cache
Ensure you have an .env file, and that the database related variables within have been set correctly.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password
I found the problem
if i restart php artisan serve the changed values are applied. this is
the norm? how can i solve this
I created a router where I output config information
I'm trying to change value from .env file, for example APP_NAME, from APP_NAME="Nuxt + Laravel" to APP_NAME="test" but the change is not displayed on the page!(of course I reloaded the page 😊)
I was trying to look through php artisan tinker
It works!
But my config remains the same. I can not solve this problem for a week now.
I cleared the cache!!! I tried php artisan cache:clear, php artisan config:clear (i tried all command for cache)
CACHE_DRIVER=file
I deleted files bootsprap/cache/*, storage/framework/cache/*.
I tried everything!!!
I have this project on the github: https://github.com/iliyaZelenko/laravel-nuxt.
Please help me, I want my project to be used by other people.
I'm trying to run Laravel Dusk and I need to use a test database. When I check the screenshot it says that the database doesn't exist. Problem is that is the database defined on .env and not the one on .env.dusk ... I've tried to rename the file to .env.dusk.local and still no luck. What am I doing wrong?
Try clearing your cache? I remember having similar issues when I first started using dusk.
php artisan cache:clear
I got the same problem. Lately I figured out that the .env file is being cached before dusk start.
I resolved it by adding
$this->artisan('config:cache');
into the createApplication() function in CreateApplication.php. It works :)
But then, if I finished the dusk test, I must run
php artisan config:cache
to get the original server running.
Edit:
later I tried simply call the
php artisan config:clear
also prevent the application caching the env variable. (Much simpler and faster)
I was able to get this to work by following these steps:
Remove .env.testing
Run php artisan dusk (This will create phpunit.dusk.xml).
Add the following to the end of this newly created file
<phpunit>
...
<php>
<server name="APP_ENV" value="local"/>
</php>
</phpunit>
You can now restore .env.testing which can still be used for phpunit testing.
ORIGINAL ANSWER
I found that if you remove .env.testing it then uses .env.dusk.local. It seems that .env.testing always take precedence.
This does not solve the problem of using a separate .env for unit tests & dusk; which is useful when running unit tests in memory and dusk tests using sqlite.
Same issue... The problem is you forgot to create config cache file for your testing env so dusk will use your current local config cache file instead. Here is the fix:
1/ duplicate .env to .env.dusk.testing and edit the following:
APP_ENV=testing
DB_DATABASE=halfwish_test #I use different MYSQL database for testing.
2/ run this cmd:
$ php artisan config:cache --env=dusk.testing && php artisan clear //clear compiled services and packages files and cache config file.
$ php artisan migrate:fresh --env=dusk.testing && php artisan seed --env=dusk.testing //this is migrating and seeding demo data to DB.
Now you can run php artisan dusk.
I seem to be having a problem with artisan reading the default config/database.php file.
When I run for php artisan migrate:status - or any other migration related commands I get
exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access
denied for user 'homestead'#'localhost' (using password: YES)'
even though the default database connection name is set to sqlite, which doesn't require credentials of any kind.
My .env has APP_ENV=local and I'm running it under the local environment with PHP 5.6.2 using Mamp.
After calling php artisan I've noticed there is a command to clear the configuration cache file php artisan config:clear - then run php artisan config:cache to cache it with the applied changes - which solved the problem.
Recently I cleaned up my tables locally, and this resulted in me deleting 'Match' table. I am now receiving errors on the production server because of this.
Locally, I ran php artisan migrate:reset, deleted the 'CreateMatchesTable' file and then php artisan migrate:refresh --seed. This worked locally and I then pushed my most recent build to the server.
Now, whenever I run php artisan migrate:refresh --seed on the production server, I'm presented with the following error:
PHP Fatal error: Class 'CreateMatchesTable' not found in
/home/forge/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php
on line 301
PHP Stack trace:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message":"Class 'CreateMatchesTable' not found","file":"\/home\/forge
\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/
Migrator.php","line":301}}
I have read about other people experiencing this and I've tried composer dump-autoload- but the problem still persists.
Also, php artisan dump-autoload unfortunately presents me with this error:
Generating optimized class loader
Compiling common classes
[ErrorException]
Array to string conversion
dump-autoload
I've deleted the site and rolled back migrations on Laravel Forge, and still, when it pulls the latest build into Forge this error occurs!
You should delete the row from your migrations table in your database.
The solution for that is
composer dump-autoload