statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 71 forks source link

S3 assets not appearing when assets are in the db but containers are not #294

Closed 1stevengrant closed 1 week ago

1stevengrant commented 1 month ago

Bug description

I wanted to keep the config for asset containers in flat files rather than them be eloquent models.

When I do this though, the container shows as having no assets.

How to reproduce

in eloquent-driver.php

'assets' => [
        'driver' => 'eloquent',
        'model' => \Statamic\Eloquent\Assets\AssetModel::class,
        'asset' => \Statamic\Eloquent\Assets\Asset::class,
    ],

keep asset_containers as file.

migrate the assets only

see the container is empty

Logs

No response

Environment

Environment
Application Name: Wild at Heart Local Platform
Laravel Version: 10.48.12
PHP Version: 8.3.7
Composer Version: 2.7.6
Environment: local
Debug Mode: ENABLED
URL: wahlocal.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: log
Queue: sync
Scout: algolia
Session: file

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 3.8.2
PHP SDK Version: 3.22.1
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED

Statamic
Addons: 1
Sites: 1
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.6.1 PRO

Statamic Addons
statamic/eloquent-driver: 4.0.0

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: file
Collection Trees: eloquent
Collections: file
Entries: eloquent
Forms: file
Global Sets: file
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: file
Revisions: file
Taxonomies: file
Terms: eloquent


### Additional details

_No response_
ryanmitchell commented 1 month ago

If you add a new asset does it appear? Just wanting to check if it's an import issue or one with the split repositories. I assume your database table (assets_meta) is empty?

1stevengrant commented 1 month ago

new assets, yeah.

The database table has over 5k rows with all of the assets

ryanmitchell commented 1 month ago

Oh thats interesting and unexpected. If you clear the artisan cache does anything change?

goellner commented 2 weeks ago

I might have the same problem. I see only folders from s3 (also seeing the .meta folder), but I can't see any files at all. Have this problem in the asset browser and when I open any page/collection page in Statamic, then all the selected assets are not resolved. when i switch to file everything is working fine.

new assets don't appear. cleared all the caches and couldn't get the assets to show. had no problems with Statamic 4.x with this, only after updating to v5

ryanmitchell commented 2 weeks ago

Ok - just for clarity, the assets are there in your asset_meta table? If you use debugbar to see the query does it align with what youre seeing in the database?

goellner commented 2 weeks ago

I have nothing in my asset_meta table. I tried running php artisan statamic:eloquent:import-assets but that didn't add anything to the db as it was stuck at 0/650 assets. had horizon running too, if thats needed. Switched to file based now and will just use that

ryanmitchell commented 2 weeks ago

Ok thats strange. I really need to get access to a repository showing this issue so I can investigate. Is that possible?

1stevengrant commented 2 weeks ago

I'll get you access to one @ryanmitchell

1stevengrant commented 2 weeks ago

prod branch

ryanmitchell commented 2 weeks ago

@1stevengrant thanks! I'd need access to S3 too - which I know is a bit of an ask. Any chance of setting me up some read only credentials?

ryanmitchell commented 1 week ago

@goellner Ive been working with Steven on this which has been really helpful to see the issue.

I think the problem is building the folder listing is painfully slow and eventually it times out in the CP, so you get nothing listed. I've proposed this PR https://github.com/statamic/eloquent-driver/pull/311 - to resolve it - can you test it out and see how that works?