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

Fix Undefined index:primary for SQLITE #223

Open
neatstudio opened this issue Oct 2, 2021 · 0 comments
Open

Fix Undefined index:primary for SQLITE #223

neatstudio opened this issue Oct 2, 2021 · 0 comments
Labels

Comments

@neatstudio
Copy link
Contributor

error : local.ERROR: Undefined index: primary {"exception":"[object] (ErrorException(code: 0): Undefined index: primary at /Volumes/documents/server/wwwroot/wechaty/crm.app.wechaty.net/vendor/reliese/laravel/src/Meta/Sqlite/Schema.php:147)

update this function:
before:

    /**
     * @param \Reliese\Meta\Blueprint $blueprint
     * @todo: Support named primary keys
     */
    protected function fillPrimaryKey(Blueprint $blueprint)
    {
        $indexes = $this->manager()->listTableIndexes($blueprint->table());

        $key = [
            'name' => 'primary',
            'index' => '',
            'columns' =>$indexes['primary']->getColumns(),
        ];

        $blueprint->withPrimaryKey(new Fluent($key));
    }

after:

    /**
     * @param \Reliese\Meta\Blueprint $blueprint
     * @todo: Support named primary keys
     */
    protected function fillPrimaryKey(Blueprint $blueprint)
    {
        $indexes = $this->manager()->listTableIndexes($blueprint->table());

        $key = [
            'name' => 'primary',
            'index' => '',
            'columns' => optional($indexes['primary']??null)->getColumns(),
        ];

        $blueprint->withPrimaryKey(new Fluent($key));
    }
neatstudio added a commit to neatstudio/laravel-reliese that referenced this issue Apr 15, 2022
robertstewart89 added a commit to robertstewart89/awesome-laravel-project that referenced this issue Sep 24, 2022
sadafrangian3 pushed a commit to sadafrangian3/laravel-dev that referenced this issue Oct 18, 2022
sadafrangian3 pushed a commit to sadafrangian3/Awesome-laravel that referenced this issue Nov 2, 2022
LeoLee90815 added a commit to LeoLee90815/laravel that referenced this issue Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants