[Module Creation] Translation base table or view not found
Created 5 years ago by finnito

Hey all,

I'm making a module and I'm getting this error when viewing http://pyro.test/admin/events/event_types on my local dev site.

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'pyrocms.pyrotest_events_event_types_translations' doesn't exist (SQL: select `pyrotest_events_event_types`.* from `pyrotest_events_event_types` left join `pyrotest_events_event_types_translations` on `pyrotest_events_event_types`.`id` = `pyrotest_events_event_types_translations`.`entry_id` where (`pyrotest_events_event_types_translations`.`locale` = en or `pyrotest_events_event_types_translations`.`locale` = en or `pyrotest_events_event_types_translations`.`locale` is null) group by `pyrotest_events_event_types`.`id` order by `pyrotest_events_event_types_translations`.`name` asc limit 15 offset 0)

I started by making a new stream in my module:

Finns-Air:pyro.test finnlesueur$ php artisan make:stream event_types finnito.module.events
Created Migration: 2018_05_10_124252_finnito.module.events__create_event_types_stream

And then I altered the migration (2018_05_10_124252_finnito.module.events__create_event_types_stream.php) to look like this:

<?php

use Anomaly\Streams\Platform\Database\Migration\Migration;

class FinnitoModuleEventsCreateEventTypesStream extends Migration
{

    /**
     * The stream definition.
     *
     * @var array
     */
    protected $stream = [
        'slug' => 'event_types',
        "translatable" => false,
        "title_column" => "event_type",
    ];

    /**
     * The stream assignments.
     *
     * @var array
     */
    protected $assignments = [
        "event_type",
        "event_type_slug",
    ];
}

And I created the required fields in 2018_05_10_193720_finnito.module.events__create_events_fields.php:

<?php

use Anomaly\Streams\Platform\Database\Migration\Migration;

class FinnitoModuleEventsCreateEventsFields extends Migration
{

    /**
     * The addon fields.
     *
     * @var array
     */
    protected $fields = [
         /* Event Types Fields */
        "event_type" => [
            "type" => "anomaly.field_type.text",
        ],
        "event_type_slug" => [
            "type" => "anomaly.field_type.slug",
            "config" => [
                "slugify" => "event_type",
            ],
        ],
    ];
}

I then ran

Finns-Air:pyro.test finnlesueur$ php artisan addon:reinstall finnito.module.events
The [finnito.module.events] module was uninstalled.
The [finnito.module.events] module was installed.

And now looking at my database I've got a pyrotest_events_event_types table and no translations tables (good).

> describe pyrocms.pyrotest_events_event_types

+ ---------- + --------- + --------- + -------- + ------------ + ---------- +
| Field      | Type      | Null      | Key      | Default      | Extra      |
+ ---------- + --------- + --------- + -------- + ------------ + ---------- +
| id         | int(10) unsigned | NO        | PRI      |              | auto_increment |
| sort_order | int(11)   | YES       |          |              |            |
| created_at | datetime  | NO        |          |              |            |
| created_by_id | int(11)   | YES       |          |              |            |
| updated_at | datetime  | YES       |          |              |            |
| updated_by_id | int(11)   | YES       |          |              |            |
+ ---------- + --------- + --------- + -------- + ------------ + ---------- +
6 rows      

But this table does not appear to have any of the correct assignments which makes me think that something has gone a little wrong but I can't seem to figure out what.

Any help would be appreciated!

Finn

finnito  —  5 years ago Best Answer

Resolved