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

Database Seed Data Not Included In Build #384

Closed
hfzm opened this issue Oct 12, 2024 · 4 comments
Closed

Database Seed Data Not Included In Build #384

hfzm opened this issue Oct 12, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@hfzm
Copy link

hfzm commented Oct 12, 2024

What were you trying to do?

Thank you for this great technology. I was trying to build my application with sqlite3 database and I was trying to seed some data in development mode.

What happened?

It shows the data without any errors in my application in development phase but when I build and package my application the seeded data is not included in the built mode.

How to reproduce the bug

Please solve this issue because we need some seeded data always either its development or production mode for example roles and permissions table data. Thanks in advance. Keep up the great work.

Package Versions

I am using the latest verson always.

PHP Version

8.1

Laravel Version

11

Node Version

18

Which operating systems have you seen this occur on?

Linux

OS version

Ubuntu 24 LTS

Notes

No response

@hfzm hfzm added the bug Something isn't working label Oct 12, 2024
@simonhamp
Copy link
Member

This is by design and is not a bug.

Consider: the database is created from scratch on each new installation of your application.

You should build your application in a way that it attempts to seed the database on first run if it's not already seeded.

@hfzm
Copy link
Author

hfzm commented Oct 19, 2024 via email

@simonhamp
Copy link
Member

You can call the db:seed Artisan command from PHP using the Artisan facade.

Wrap that call in an if which checks your DB first to see if it has been seeded. (You might want an explicit record in one of your seeders that gives you a clear signal that seeding has happened)

Put that whole block somewhere that will run every time your app boots - e.g. the NativeServiceProvider - so that it runs every time.

@hfzm
Copy link
Author

hfzm commented Oct 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants