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

No such table thing_sheet_models #29

Open
wrabit opened this issue May 23, 2020 · 2 comments
Open

No such table thing_sheet_models #29

wrabit opened this issue May 23, 2020 · 2 comments

Comments

@wrabit
Copy link

wrabit commented May 23, 2020

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: thing_sheet_models (SQL: select * from "thing_sheet_models") in file /***/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 671
namespace App;

use Grosv\EloquentSheets\SheetModel;

class ThingSheetModel extends SheetModel
{
    protected $spreadsheetId = '***';
    protected $sheetId = '0';
    protected $headerRow = '1';

    /**
     * Save things and rebuild recurrences
     */
    public function onForget()
    {
        $things = ThingSheetModel::all();
@wrabit
Copy link
Author

wrabit commented May 23, 2020


#0 /project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(64): PDO->prepare('select * from \"...', Array)
#1 /project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(331): Doctrine\\DBAL\\Driver\\PDOConnection->prepare('select * from \"...')
#2 /project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from \"...', Array)
#3 /project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\\Database\\Connection->runQueryCallback('select * from \"...', Array, Object(Closure))
#4 /project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(339): Illuminate\\Database\\Connection->run('select * from \"...', Array, Object(Closure))
#5 /project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2178): Illuminate\\Database\\Connection->select('select * from \"...', Array, true)
#6 /project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2166): Illuminate\\Database\\Query\\Builder->runSelect()
#7 /project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2661): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}()
#8 /project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2167): Illuminate\\Database\\Query\\Builder->onceWithColumns(Array, Object(Closure))
#9 /project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(539): Illuminate\\Database\\Query\\Builder->get(Array)
#10 /project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(523): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#11 /project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(488): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#12 /project/app/ThingSheetModel.php(20): Illuminate\\Database\\Eloquent\\Model::all()
#13 /project/vendor/grosv/eloquent-sheets/src/ForgetSheet.php(28): App\\ThingSheetModel->onForget()
#14 /project/vendor/grosv/eloquent-sheets/src/ForgetSheet.php(16): Grosv\\EloquentSheets\\ForgetSheet->triggerCallback('sushi-thing-she...')

So I am hooking into the forget action so in ForgetSheet I am calling an 'onForget' method in the sheet model.

namespace Grosv\EloquentSheets;

use Illuminate\Support\Facades\File;
use function logger;
use function method_exists;
use function str_replace;

class ForgetSheet
{
    public function execute($id)
    {
        File::delete(config('sushi.cache-path').'/'.$id.'.sqlite');

        $this->triggerCallback($id);

        return response()->noContent();
    }

    protected function triggerCallback($id)
    {
        $class = 'App\\' . \Str::studly(str_replace('sushi-', '', $id));
        $model = new $class;

        if(method_exists($model, 'onForget')) {
            $model->onForget();
        }
    }
} 

@edgrosvenor
Copy link
Collaborator

The problem with this solution is that Sushi doesn't give me any flexibility in naming the file so I can't reliably infer the fully qualified name of the model.

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

2 participants