Updating organic groups module in Drupal - 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.

Related

cannot drop NOT NULL constraint on a DEFAULT ON NULL column

I have a table A with schema.
Name Null? Type
-------- -------- ------------
NAME VARCHAR2(10)
TABLE_ID NOT NULL NUMBER
I wanted Table_ID to be an auto-incrementing column so I created a sequence.
create sequence table_id minvalue 1 start with 1 cache 10;
and I modified the Table_ID column as
alter table A
modify table_id default on null table_id.nextval;
now I cannot drop the table or the column or the constraint.
It is giving me this error.
An error was encountered performing the requested operation:
ORA-30667: cannot drop NOT NULL constraint on a DEFAULT ON NULL column
30667.0000 - "cannot drop NOT NULL constraint on a DEFAULT ON NULL column"
*Cause: The NOT NULL constraint on a DEFAULT ON NULL column could not be
dropped.
*Action: Do not drop the NOT NULL constraint on a DEFAULT ON NULL column.
The only way to drop the constraint is to remove the ON NULL
property of the column default.
Vendor code 30667
I have tried to purge the recyclebin but it is not working either.
I read other posts but none of this seems to make sense.
Please help.
If you just need to remove the constraint, just set a default value on that column. The constraint will be removed automatically:
alter table a modify table_id default 0;
Full example:
create table a(name varchar2(10), table_id number not null);
create sequence table_id minvalue 1 start with 1 cache 10;
alter table a modify table_id default on null table_id.nextval;
select * from user_constraints where table_name = 'A'; -- one constraint "TABLE_ID" IS NOT NULL
alter table a drop constraint SYS_C0026367; -- ORA-30667: cannot drop NOT NULL constraint on a DEFAULT ON NULL column
alter table a modify table_id default 0;
alter table a drop constraint SYS_C0026367; -- ORA-02443: Cannot drop constraint - nonexistent constraint
select * from user_constraints where table_name = 'A'; -- the constraint was dropped automatically
I ran this code on Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production and it worked fine:
create table a(name varchar2(10), table_id number not null);
create sequence table_id minvalue 1 start with 1 cache 10;
alter table a modify table_id default on null table_id.nextval;
drop table a;
Table A created.
Sequence TABLE_ID created.
Table A altered.
Table A dropped.

sqlite integer primary key not null constraint failed

According to the SQLite documentation / FAQ a column declared INTEGER PRIMARY KEY will automatically get a value of +1 the highest of the column if omitted.
Using SQLite version 3.22.0 2018-01-22 18:45:57
Creating a table as follows:
CREATE TABLE test (
demo_id INTEGER PRIMARY KEY NOT NULL,
ttt VARCHAR(40) NOT NULL,
basic VARCHAR(25) NOT NULL,
name VARCHAR(255) NOT NULL,
UNIQUE(ttt, basic) ON CONFLICT ROLLBACK
) WITHOUT ROWID;
Then inserting like this:
INSERT INTO test (ttt, basic, name) VALUES ('foo', 'bar', 'This is
a test');
gives:
Error: NOT NULL constraint failed: test.demo_id
sqlite>
When it is expected to create a record with a demo_id value of 1. Even if the table already contains values, it'll fail inserting the row without explicitly specifying the id with the same error.
What am I doing wrong?
The documentation says that you get autoincrementing values for the rowid. But you specified WITHOUT ROWID.

How can I use IF statements in Teradata without using BTEQ

I'm trying to create some deployment tools and I don't want to use BTEQ. I've been trying to work with the Teradata.Client.Provider in PowerShell but I'm getting syntax errors on the creation of a table.
[Teradata Database] [3706] Syntax error: expected something between
';' and the 'IF' keyword.
SELECT * FROM DBC.TablesV WHERE DatabaseName = DATABASE AND TableName = 'MyTable';
IF ACTIVITYCOUNT > 0 THEN GOTO EndStep1;
CREATE MULTISET TABLE MyTable ,
NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
MyColId INTEGER GENERATED ALWAYS AS IDENTITY
(START WITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 2147483647
NO CYCLE)
NOT NULL,
MyColType VARCHAR(50) NULL,
MyColTarget VARCHAR(128) NULL,
MyColScriptName VARCHAR(256) NULL,
MyColOutput VARCHAR(64000) NULL,
isMyColException BYTEINT(1) NULL,
ExceptionOutput VARCHAR(64000) NULL,
MyColBuild VARCHAR(128) NULL,
MyColDate TIMESTAMP NOT NULL
)
PRIMARY INDEX PI_MyTable_MyColLogId(MyColLogId);
LABEL EndStep1;
I would rather not use BTEQ as I've not found it has worked well in other deployment tools we have created and requires a bit of hacks. Is there anything I can use that would avoid using that tool?
What Parse error?
The CREATE will fail due to double INTEGER in MyColId and VARCHAR(max) in ExceptionOutput, it's an unknown datatype in Teradata.

Drupal PDOException error while enabling a module

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.

ORA-00907: missing right parenthesis when creating tables

I am trying to create 3 tables but I am getting this error:
CREATE TABLE dj_abonent
(
dj_klientID INT NOT NULL PRIMARY KEY,
emer_klienti varchar2(10),
mbiemer_klienti VARCHAR2(10),
sasia_cel INT
);
CREATE TABLE dj_phones
(
phone_number varchar2(12),
activated number(1) default 0,
activation_date date default null,
CONSTRAINT dj_phone_number_check
CHECK (substr(phone_number,1,5) in( '35566','35567','35568','35569') ),
CONSTRAINT dj_activated_check
CHECK (activated in(1,0) )
dj_KlientID int FOREIGN KEY REFERENCES dj_Abonenti(dj_KlientID)
);
CREATE TABLE dj_telef
(
start_time date,
end_time date,
abonent_1 varchar2(10),
abonent_2 varchar2(10)
);
Error at Command Line : 26 Column : 17
Error report -
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
The line number is from your SQL Developer script window, which isn't entirely helpful as it doesn't seem to align with the issue. There may be other things too but you're missing a comma after your check constraint (just like a previous question). But you should put the constraints at the end of the command:
CREATE TABLE dj_phones
(
phone_number varchar2(12),
activated number(1) default 0,
activation_date date default null,
dj_KlientID int FOREIGN KEY REFERENCES dj_Abonenti(dj_KlientID)
CONSTRAINT dj_phone_number_check
CHECK (substr(phone_number,1,5) in( '35566','35567','35568','35569') ),
CONSTRAINT dj_activated_check
CHECK (activated in(1,0) )
);
You might find it easier to debug these issues if you ran one statement at a time, either with the run statement command (control-enter), or by highlighting the text one one command and using run script (F5).

Resources