Drupal PDOException error while enabling a module - drupal

I have installed the ThemeTastic theme and themetastic_features module, after enabling the themetastic_features I get the following error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1072
Key column 'field_slider_block_bid' doesn't exist in table: CREATE
TABLE {field_data_field_slider_block} ( entity_type VARCHAR(128) NOT
NULL DEFAULT '' COMMENT 'The entity type this data is attached to',
bundle VARCHAR(128) NOT NULL DEFAULT '' COMMENT 'The field instance
bundle to which this row belongs, used when deleting a field
instance', deleted TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean
indicating whether this data item has been deleted', entity_id INT
unsigned NOT NULL COMMENT 'The entity id this data is attached to',
revision_id INT unsigned NULL DEFAULT NULL COMMENT 'The entity
revision id this data is attached to, or NULL if the entity type is
not versioned', language VARCHAR(32) NOT NULL DEFAULT '' COMMENT
'The language for this data item.', delta INT unsigned NOT NULL
COMMENT 'The sequence number for this data item, used for multi-value
fields', field_slider_block_moddelta VARCHAR(129) NOT NULL DEFAULT
'', PRIMARY KEY (entity_type, entity_id, deleted, delta,
language), INDEX entity_type (entity_type), INDEX bundle
(bundle), INDEX deleted (deleted), INDEX entity_id
(entity_id), INDEX revision_id (revision_id), INDEX language
(language), INDEX field_slider_block_bid
(field_slider_block_bid), INDEX field_slider_block_moddelta
(field_slider_block_moddelta) ) ENGINE = InnoDB DEFAULT CHARACTER
SET utf8 COMMENT 'Data storage for field 19 (field_slider_block)';
Array ( ) in db_create_table() (line 2720 of
/home/venice/domains/venice-stone.com/public_html/includes/database/database.inc).
Also I realized that after getting this error, when I enable any of my modules I get the same error too!
Also I took a look at database and could not find the table that this error is talking about!?
What should I do to solve the problem!?

It seems that it is the problem of features module!
https://www.drupal.org/node/1604728
https://www.drupal.org/node/1679572
I tried unistalling and installing ThemeTastic: Features module and now everything seems to work well.

Related

NULL statement doesn't fill the empty spaces in Sqlite

I'm having trouble with NULL statement in SQLITE. I added NULL in cases there is no info to be filled, but once I run the code the IDE throws an error.
CREATE TABLE tenants (
Apartment_Number INT(4),
Family_Name VARCHAR(8) NULL,
Sur_Name VARCHAR(14) NULL,
Home_Number INT(4),
Mobile_Number int(10),
PRIMARY KEY (Apartment_Number )
);
INSERT INTO tenants
VALUES
(101,,,201,0544431263),
(102,,,202,0544431263),
(103,'Shklobin','marta',203,0544431263),
(104,'arman','charles',204,0544431263);
SELECT * FROM tenants;
The empty spaces are where I hope the IDE will fill with NULL values.
The error I receive:
Error: near line 12: near ",": syntax error.
If I remove the NULL statement, the IDE runs the code with no errors.
Official documentation indicates that
The default value of each column is NULL.
The default behavior is also to allow NULL in each column. The behavior only changes if NOT NULL and/or DEFAULT ... constraints are specified. You should get the same error whether or not you have the lone NULL keyword as shown in the question code. My testing shows that the following does not suppress the error as implied in the question--in other words, the following change results in the same error.
Family_Name VARCHAR(8),
Sur_Name VARCHAR(14),
The following alternative INSERT statements will work:
INSERT INTO tenants
(Apartment_Number, Home_Number, Mobile_Number)
VALUES
(101,201,0544431263),
(102,202,0544431263);
INSERT INTO tenants
VALUES
(103,'Shklobin','marta',203,0544431263),
(104,'arman','charles',204,0544431263);
or
INSERT INTO tenants
VALUES
(101, NULL, NULL,201,0544431263),
(102, NULL, NULL,202,0544431263),
(103,'Shklobin','marta',203,0544431263),
(104,'arman','charles',204,0544431263);

MariaDB - Foreign key constraint incorrect?

I tried to re-engineer a database, that I use at work. The one at work is MS Access. At home, it's MariaDB. For convenience, I use MySQL Workbench.
When sending the complete SQL dump to the server, I get an error concerning some foreign key not being correctly formed. I guess, it is a minor mistake, but still I cannot find it.
My InnoDB status tells me this:
LATEST FOREIGN KEY ERROR
2018-10-03 00:18:29 409c7450 Error in foreign key constraint of table `mydb`.`IF`:
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblBelegPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tblBelege_tblECKassenschnittPositionen10`
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblECKassenschnittPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
Create table '`mydb`.`IF`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near '
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblBelegPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tblBelege_tblECKassenschnittPositionen10`
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblECKassenschnittPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB'.
The really weird thing is that I do not have any table named "IF"...
Can anyone make heads or tails of this for me? That would be very much appreciated.
-- Table `mydb`.`tblBelegPositionen`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`tblBelegPositionen` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `mydb`.`tblBelegPositionen` (
`belegposid` INT NOT NULL AUTO_INCREMENT,
`belegposBetrag` DOUBLE NOT NULL,
`zahlartfID` INT NOT NULL,
`belegfID` INT NOT NULL,
PRIMARY KEY (`belegposid`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- Table `mydb`.`tblECKassenschnittPositionen`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`tblECKassenschnittPositionen` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `mydb`.`tblECKassenschnittPositionen` (
`ecposid` INT NOT NULL AUTO_INCREMENT,
`belegfID` INT NOT NULL,
`ecposBetrag` DOUBLE NOT NULL,
`kassenschnittfID` INT NOT NULL,
PRIMARY KEY (`ecposid`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- Table `mydb`.`tblBelege`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`tblBelege` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `mydb`.`tblBelege` (
`belegid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`belegKassierer` INT NOT NULL,
`belegDatum` DATETIME NOT NULL,
`kassefID` INT NOT NULL,
`belegSchicht` INT NULL,
`gvfID` INT NOT NULL,
`belegJahr` YEAR NULL,
`belegDruckErfolgt` TINYINT(1) NULL,
`belegDruckDatum` DATETIME NULL,
`belegPeriodenfremdeBuchung` TINYINT(1) NULL,
PRIMARY KEY (`belegid`, `gvfID`, `kassefID`),
CONSTRAINT `fk_tblBelege_tblBelegPositionen10`
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblBelegPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_tblBelege_tblECKassenschnittPositionen10`
FOREIGN KEY (`belegid`)
REFERENCES `mydb`.`tblECKassenschnittPositionen` (`belegfID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SHOW WARNINGS;
Ok, so there are a couple of things to know here, as there were a couple of errors. You must check all the items that the error mentions, for correctness, to avoid trouble.
The cannot find an index in the referenced table portion of the error message means that the column/field specified in the REFERENCES clause must be indexed in the other table.
Then, the column type definition of the column specified in the FOREIGN KEY clause must match the column type of the column specified in the REFERENCES clause too, so even though the first item corrects part of the problem, there will still be an error related to another portion of the message: ...or column types in the table and the referenced table do not match.
So, to fix item 1, run these 2 queries:
ALTER TABLE `tblbelegpositionen` ADD INDEX(`belegfID`);
ALTER TABLE `tbleckassenschnittpositionen` ADD INDEX(`belegfID`);
Then to fix item 2, I had to change the first column of table tblBelege
from this:
`belegid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
to this:
`belegid` INT NOT NULL,
...so that they matched the same type as the belegfID column as defined in the other tables. After those two changes, I was able to successfully run your CREATE TABLE `tblBelege` statement.
So, to recap:
Run your create table statements for tblbelegpositionen and
tbleckassenschnittpositionen.
Then run the 2 ALTER statements shown above for item 1.
Modify the first column of table tblBelege to match the column types as defined to belegfID in the other tables for item 2.
Then run your modified CREATE TABLE statement (with the item 2 change applied) to create the tblBelege table.
I'm a little confused about the same FOREIGN KEY referencing 2 different tables, but if it works for you, then ok. (not saying that it cannot be done, I've never used a foreign key that way) Perhaps you meant the opposite, to have a foreign key in the other 2 tables (1 in each table) that refer to tblBelege instead? If so, then you could add unsigned to the type definition for belegfID and it would work, and would not need the change that I mentioned with item 2.
Oh, and after you run the ALTER statements, you can view the table structure by running:
SHOW CREATE TABLE `tblbelegpositionen`;
SHOW CREATE TABLE `tbleckassenschnittpositionen`;
...to get the KEY definition that was added to include with your CREATE TABLE statements. Since they both create the same key, you really only need to run one of those statements and then add the KEY definition to both table statements.

A primary key in ORACLE 11g became nullable

I have a table named 'ROUTE'. What "desc ROUTE" does is as follow:
Name Null Type
-------------------- ---- --------------
ROUTE_GUID RAW(16 BYTE)
LINE_GUID RAW(16 BYTE)
EVENT_GUID RAW(16 BYTE)
DESCRIPTION VARCHAR2(254)
Where ROUTE_GUID IS PK. When I tried altering the table, it showed "ORA-01442: column to be modified to NOT NULL is already NOT NULL". The real problem is that a .NET application has to use this table but it cannot unless a non-nullable column is found. There are also many database views associated with this table so that these view cannot be retrieved by .NET as well. Anyone got the same problem?
I came across this issue in Oracle 12g r 2. The desc MY_TABLE did not show the NOT NULL for a column that did have a NOT NULL constraint. Querying the DBA_TAB_COLS table for the NULLABLE column did not show it either. If I queried the DBA_CONS_COLUMNS and
DBA_CONSTRAINTS it did show up! The web site https://logic.edchen.org/how-to-resolve-ora-01442-column-to-be-modified-to-not-null-is-already-not-null/ almost helps; it showed the case where the constraint was in DISABLED status; my situation, the status was ENABLED. I just did a disable followed by an enable, and it worked; the NOT NULL is displayed now.
Code to display NOT NULL constraint name:
select a.constraint_name, b.status
from dba_cons_columns a
inner join dba_constraints b
on a.constraint_name = b.constraint_name
where a.table_name = 'MY_TABLE'
and a.owner = 'SCOTT' and a.owner=b.owner
and a.column_name = 'USER_NAME'
and b.constraint_type = 'C' and search_condition_vc like '%NOT NULL';
Code to disable and enable constraint:
alter table scott.my_table modify constraint SYS_C0019940 DISable;
alter table scott.my_table modify constraint SYS_C0019940 ENable;

flyway unable to init or migrate after a clean

I've just performed a clean operation, i've added a new schema one the prop file then ran clean again to remove that schema from db then when i tried to do a migrate it doesnt allow me i get the following:
Creating Metadata table: [xx].[schema_version]
Error executing statement at line 17: CREATE TABLE [xx].[schema_version] (
[version_rank] INT NOT NULL,
[installed_rank] INT NOT NULL,
[version] NVARCHAR(50) NOT NULL,
[description] NVARCHAR(200),
[type] NVARCHAR(20) NOT NULL,
[script] NVARCHAR(1000) NOT NULL,
[checksum] INT,
[installed_by] NVARCHAR(30) NOT NULL,
[installed_on] DATETIME NOT NULL DEFAULT GETDATE(),
[execution_time] INT NOT NULL,
[success] BIT NOT NULL
);
CREATE INDEX [schema_version_vr_idx] ON [xx].[schema_version] ([version_rank]);
CREATE INDEX [schema_version_ir_idx] ON [xx].[schema_version] ([installed_rank]);
CREATE INDEX [schema_version_s_idx] ON [xx].[schema_version] ([success]);
Also when i tried to initialize it sing init i get the following:
Creating Metadata table: [xx].[schema_version]
Error executing statement at line 17: CREATE TABLE [xx].[schema_version] (
[version_rank] INT NOT NULL,
[installed_rank] INT NOT NULL,
[version] NVARCHAR(50) NOT NULL,
[description] NVARCHAR(200),
[type] NVARCHAR(20) NOT NULL,
[script] NVARCHAR(1000) NOT NULL,
[checksum] INT,
[installed_by] NVARCHAR(30) NOT NULL,
[installed_on] DATETIME NOT NULL DEFAULT GETDATE(),
[execution_time] INT NOT NULL,
[success] BIT NOT NULL
);
CREATE INDEX [schema_version_vr_idx] ON [xx].[schema_version] ([version_rank]);
CREATE INDEX [schema_version_ir_idx] ON [xx].[schema_version] ([installed_rank]);
CREATE INDEX [schema_version_s_idx] ON [xx].[schema_version] ([success]);
ERROR: Occured in com.googlecode.flyway.core.dbsupport.SqlScript.execute() at line 91
ERROR: Caused by com.microsoft.sqlserver.jdbc.SQLServerException: The specified schema name "xx" either does not exist or you do not have permission to use it.
ERROR: Occured in com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError() at line 197
Please not that I've dropped all the objects and I can confirm they do not exist on my DB instance.
How can I overcome this? I am concerned when using the tool in dev and prod environment we can't just delete the db instance and start again. at this point I cant use the tool to do the migration and i dont want to delete the db to overcome this issue.
Flyway's schema creation is currently an all or nothing deal. Either all schemas are missing and then all will be created or at least one schema is present and then none will be created.
For you this means that you must either create xx yourself or drop the other schemas first.

Updating organic groups module in Drupal

I've taken over a Drupal website. I'm trying to update the og module. It is currently version 1. I tried to upgrade it to the latest version but when I ran update.php it failed. So I thought I'd just try updating it to version 1.4. However, when I did this I then got the following errors when I ran update.php:
# user warning: Table 'og_ancestry' already exists query: CREATE TABLE og_ancestry ( nid int(11) NOT NULL, group_nid int(11) NOT NULL, is_public int(1) NULL, KEY (nid), KEY (group_nid) ) /*!40100 DEFAULT CHARACTER SET utf8 */; in /homepages/0/d309344694/htdocs/openup6/sites/default/modules/ogr/og.install on line 218.
# user warning: Unknown column 'is_public' in 'field list' query: INSERT INTO og_ancestry (nid, group_nid, is_public) SELECT nid, gid, is_public FROM og_migrate in /homepages/0/d309344694/htdocs/openup6/sites/default/modules/ogr/og.install on line 239.
# warning: array_merge() [function.array-merge]: Argument #2 is not an array in /homepages/0/d309344694/htdocs/openup6/update.php on line 174.
# user warning: Duplicate entry 'openup-og_views-1' for key 2 query: UPDATE blocks SET module = 'og_views', delta = '1' WHERE module = 'og' AND delta = '5' in /homepages/0/d309344694/htdocs/openup6/sites/default/modules/ogr/og.install on line 377.
# user warning: Unknown column 'selective' in 'og' query: ALTER TABLE og CHANGE `selective` `og_selective` INT NOT NULL DEFAULT 0 in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'register' in 'og' query: ALTER TABLE og CHANGE `register` `og_register` TINYINT NOT NULL DEFAULT 0 in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'theme' in 'og' query: ALTER TABLE og CHANGE `theme` `og_theme` VARCHAR(255) DEFAULT NULL in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'directory' in 'og' query: ALTER TABLE og CHANGE `directory` `og_directory` TINYINT NOT NULL DEFAULT 0 in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'description' in 'og' query: ALTER TABLE og CHANGE `description` `og_description` VARCHAR(255) DEFAULT NULL in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'notification' in 'og' query: ALTER TABLE og CHANGE `notification` `og_notification` TINYINT NOT NULL DEFAULT 0 in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Unknown column 'language' in 'og' query: ALTER TABLE og CHANGE `language` `og_language` VARCHAR(12) NOT NULL DEFAULT '' in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# user warning: Duplicate column name 'og_private' query: ALTER TABLE og CHANGE `private` `og_private` TINYINT NOT NULL DEFAULT 0 in /homepages/0/d309344694/htdocs/openup6/includes/database.mysql-common.inc on line 520.
# warning: Missing argument 1 for og_notifications_menu() in /homepages/0/d309344694/htdocs/openup6/sites/default/modules/ogr/og_notifications/og_notifications.module on line 15.
and
Update #6002
* Failed: ALTER TABLE {og} CHANGE `selective` `og_selective` INT NOT NULL DEFAULT 0
* Failed: ALTER TABLE {og} CHANGE `register` `og_register` TINYINT NOT NULL DEFAULT 0
* Failed: ALTER TABLE {og} CHANGE `theme` `og_theme` VARCHAR(255) DEFAULT NULL
* Failed: ALTER TABLE {og} CHANGE `directory` `og_directory` TINYINT NOT NULL DEFAULT 0
* Failed: ALTER TABLE {og} CHANGE `description` `og_description` VARCHAR(255) DEFAULT NULL
* Failed: ALTER TABLE {og} CHANGE `notification` `og_notification` TINYINT NOT NULL DEFAULT 0
* Failed: ALTER TABLE {og} CHANGE `language` `og_language` VARCHAR(12) NOT NULL DEFAULT ''
* Failed: ALTER TABLE {og} CHANGE `private` `og_private` TINYINT NOT NULL DEFAULT 0
Can anyone help?
If I understand you correctly:
You were running OG version 1
You tried to update it to the latest version i.e. version 2.1 -- that update failed
So now you tried to update it to version 1.4 -- That has failed too.
Unfortunately, what has happened is that the database tables have been changed to correspond to the "schema" for version 2.1. That upgrade did not succeed completely for an unknown reason (difficult to say.. could be so many things).
Now you cannot upgrade to 1.4. Actually that would mean "downgrading". Thats not possible in Drupal.
You should always take a database dump before performing an upgrade. So many things can go wrong.

Resources