Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: EE 2.6, Assets 2.1.2 DB error

Status Resolved
Add-on / Version Publisher
Severity Trivial
EE Version 24

Timothy Kelty

May 03, 2013

Latest 0.98.7 from devotee.
With debugging on, I get this error.

A Database Error Occurred
Error Number: 1060

Duplicate column name ‘selection_id’

ALTER TABLE `exp_assets_selections` ADD `selection_id` int(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY AFTER `file_id`

Filename: xxxx/vendor/ee_third_party/publisher/libraries/Publisher/fieldtypes/Publisher_assets.php

Line Number: 112

#1

BoldMinded (Brian)

What happens if you change that install method to this?

public function install()
    {
        if (ee()->db->table_exists('assets_selections') AND ! ee()->db->field_exists('publisher_lang_id', 'assets_selections')) 
        {
            // Create a unique ID column since Assets does not have one, it makes post_save easier for Publisher.
            // ee()->db->query("ALTER TABLE `". ee()->db->dbprefix ."assets_selections` ADD `selection_id` int(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY AFTER `file_id`");
            // Move it to the front.
            ee()->db->query("ALTER TABLE `". ee()->db->dbprefix ."assets_selections` MODIFY COLUMN `file_id` int(10) AFTER `selection_id`");
            ee()->db->query("ALTER TABLE `". ee()->db->dbprefix ."assets_selections` ADD `publisher_lang_id` int(4) NOT NULL DEFAULT  ". ee()->publisher_lib->default_lang_id ." AFTER `entry_id`");
            ee()->db->query("ALTER TABLE `". ee()->db->dbprefix ."assets_selections` ADD `publisher_status` varchar(24) NULL DEFAULT '". PUBLISHER_STATUS_OPEN ."' AFTER `publisher_lang_id`");

            $this->EE->db->query("ALTER TABLE `{$this->EE->db->dbprefix}{$this->table}` DROP PRIMARY KEY");
            $this->EE->db->query("ALTER TABLE `{$this->EE->db->dbprefix}{$this->table}` ADD PRIMARY KEY (selection_id)");
        }
    }
#2

BoldMinded (Brian)

Wait, when did you get that error?

#3

BoldMinded (Brian)

Better question, what were you doing when that error happened?

#4

Timothy Kelty

Happened on any request in the CP or frontend template.

#5

BoldMinded (Brian)

And does that table already have publisher_lang_id as a column?

#6

Timothy Kelty

It doesn’t. Should I uninstall/reinstall/run publisher P&T addon update?

#7

BoldMinded (Brian)

Yeah, click that link at the bottom of the Publisher settings page.

#8

Timothy Kelty

Yep, ran that, no change.

#9

Timothy Kelty

Commenting that line out of the install method and running the PT update worked, though!

#10

BoldMinded (Brian)

And the selection_id column is there? I just did a couple of installs and uninstalls and couldn’t get that error to happen. What version of MySQL?

#11

Timothy Kelty

The selection ID col was, but no the others.

Maybe it died in mid-install or something originally?

#12

BoldMinded (Brian)

Maybe. Just to confirm though, you see the same thing as this? https://www.evernote.com/shard/s9/sh/7f533e41-1c0f-45e0-a247-39c61883d8fc/db7e6551a78397c7761e9af0b00cf023

#13

Timothy Kelty

Yep, after I commented out the line and ran the PT updater, my table looks just like that.

#14

BoldMinded (Brian)

Very strange. I’ll try to look into this some more, but at least now its working.

Login to reply