Moodle foreign keys - database

i am installing moodle (2.2 or 2.5) and modified the sql generator.php to have foreign keys and map the database for studies proposes and i get this allways, i am using 5.5.27 - MySQL Community Server by the way
Debug info: Table 'config' already exists CREATE TABLE config ( id
BIGINT(10) NOT NULL auto_increment, name VARCHAR(255) CHARACTER SET
utf8 COLLATE utf8_spanish_ci NOT NULL DEFAULT '', value LONGTEXT
CHARACTER SET utf8 COLLATE utf8_spanish_ci NOT NULL, CONSTRAINT
PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 DEFAULT
COLLATE = utf8_spanish_ci Error code: ddlexecuteerror Stack trace:
line 429 of \lib\dml\moodle_database.php: ddl_change_structure_exception thrown
line 842 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 88 of \lib\ddl\database_manager.php: call to mysqli_native_moodle_database->change_database_structure()
line 77 of \lib\ddl\database_manager.php: call to database_manager->execute_sql()
line 417 of \lib\ddl\database_manager.php: call to database_manager->execute_sql_arr()
line 369 of \lib\ddl\database_manager.php: call to database_manager->install_from_xmldb_structure()
line 1479 of \lib\upgradelib.php: call to database_manager->install_from_xmldb_file()
line 203 of \admin\index.php: call to install_core()
i found this is a minor bug at https://tracker.moodle.org/browse/MDL-20437 anyways its for the version 1.9 but this is not the version i try to install
i have searched so far and no solution!. did someone actually fix this

It seems, you are naming your table "config" which is a big NO-NO. You are supposed to prefix your table names by the name of your module. E.g. if your module is called "mymodule", it's config table name should be "mymodule_config". I hope, this fixes it for you.
See this Moodle dev wiki article for more information.

Related

What is the column name restriction of openGauss database creation table

Create a table statement as follows:
[omm#tpl-centos7 bin]$ ./gsql -ddev -Uomm -p26000 -f test.sql
gsql:test.sql:7: ERROR: column name “tid” conflicts with a system column name
total time: 0 ms
[omm#tpl-centos7 bin]$ cat test.sql
CREATE TABLE if not exists ax_quarantine_rcpt
(
“tid” varchar2(255) NOT NULL,
rcpt varchar2(255) NOT NULL,
org_id varchar2(60) NOT NULL,
PRIMARY KEY (“tid”,rcpt)
);
error:column name “tid” conflicts with a system column name
Looking at the documentation, it says reserved words must never be used as other identifiers, but tid is also not in the keyword
Referring to the Internet with double quotation marks does not work, solve
It may be a version problem. He described that the tid is occupied by the system view field. I can use the latest compiled version. It is recommended to use the latest version.
If you cannot compile it yourself, you can use the container version. https://hub.docker.com/repository/docker/enmotech/opengauss

Issue while installing Bugzilla on Window 10

I have tried to install the Bugzilla-5.0.4 version in my Windows 10 OS system.
Also, I have installed MySQL 8.0 version along to maintain the all Bug data assets. I have installed all plugin which were not install.
I have provided all database configuration in localconfig file.
But i am facing issue while running checksetup.pl command .
Few last lines taken from the CMD window while executing below command.
c:\Bugzilla>perl checksetup.pl
* This is Bugzilla 5.0.4 on perl 5.24.3
* Running on Win10 Build 17134
Checking perl modules...
.
.
.
.
.
Checking for DBD-mysql (v4.001) ok: found v4.033
Checking for MySQL (v5.0.15) ok: found v8.0.15
Adding new table groups...
DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups (
id mediumint auto_increment PRIMARY KEY NOT NULL,
name varchar(255) N' at line 1 [for Statement "CREATE TABLE groups (
id mediumint auto_increment PRIMARY KEY NOT NULL,
name varchar(255) NOT NULL,
description mediumtext NOT NULL,
isbuggroup tinyint NOT NULL,
userregexp tinytext DEFAULT '' NOT NULL,
isactive tinyint DEFAULT 1 NOT NULL,
icon_url tinytext
) ENGINE = InnoDB CHARACTER SET utf8"] at Bugzilla/DB.pm line 837.
Bugzilla::DB::_bz_add_table_raw(Bugzilla::DB::Mysql=HASH(0x913ec90), "groups", HASH(0x94cf7c8)) called at Bugzilla/DB.pm line 796
Bugzilla::DB::bz_add_table(Bugzilla::DB::Mysql=HASH(0x913ec90), "groups", HASH(0x94cf7c8)) called at Bugzilla/DB.pm line 509
Bugzilla::DB::bz_setup_database(Bugzilla::DB::Mysql=HASH(0x913ec90)) called at Bugzilla/DB/Mysql.pm line 558
Bugzilla::DB::Mysql::bz_setup_database(Bugzilla::DB::Mysql=HASH(0x913ec90)) called at checksetup.pl line 121
I really appreciate your help.
Thank you.
Resolved.
The issue is mainly with current BugZilla 5.0.4 version. The scripts to generate the tables and all relevant asset in MySql 8.0 doesn't support UTF-8.
Thus i am looking for downgrading the MySQL version to 5x versions.
Below are external links for your reference.
https://bugzilla.mozilla.org/show_bug.cgi?id=1424043
https://groups.google.com/forum/#!topic/mozilla.community.india/LRwxmGJ2yNQ

How to make the 'public' schema default in a Scala Play project that uses PostgreSQL?

I am not sure if my issue connecting to the Scala Play 2.5.x Framework or to PostgreSQL so I am going to describe my setup.
I am using the Play 2.5.6 with Scala and PostgreSQL 9.5.4-2 from the BigSQL Sandboxes. I use the Play Framework default evolution package to manage the DB versions.
I created a new database in BigSQL Sandbox's PGSQL and PGSQL created a default schema called public. I use this schema for development.
I would like to create a table with the following script (1.sql in DB evolution config):
# Initialize the database
# --- !Ups
CREATE TABLE user (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
creation_date TIMESTAMP NOT NULL
);
# --- !Downs
DROP TABLE user;
Besides that I would like to read the table with a code like this:
val resultSet = statement.executeQuery("SELECT id, name, email FROM public.user WHERE id=" + id.toString)
I got an error if I would like to execute any of the mentioned code or even if I use the CREATE TABLE... code in pgadmin. The issue is with the user table name. If I prefix it with public (i.e. public.user) everything works fine.
My questions are:
Is it normal to prefix the table name with the schema name every time? It seems to odd to me.
How can I make the public schema a default option so I do not have to qualify the table name? (e.g. CREATE TABLE user (...); will not throw an error)
I tried the following:
I set the search_path for my user: ALTER USER my_user SET search_path to public;
I set the search_path for my database: ALTER database "my_database" SET search_path TO my_schema;
search_path correctly shows this: "$user",public
I got the following errors:
In Play: p.a.d.e.DefaultEvolutionsApi - ERROR: syntax error at or near "user"
In pgadmin:
ERROR: syntax error at or near "user"
LINE 1: CREATE TABLE user (
********** Error **********
ERROR: syntax error at or near "user"
SQL state: 42601
Character: 14
This has nothing to do with the default schema. user is a reserved word.
You need to use double quotes to be able to create such a table:
CREATE TABLE "user" (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
creation_date TIMESTAMP NOT NULL
);
But I strongly recommend not doing that. Find a different name that does not require a quoted identifier.

Cayenne, Postgres: primary key generation

I'm using Cayenne 3.2M1 and Postgres 9.0.1 to create a database. Right now I'm having problems with the primary key generation of Cayenne since I have tables with more than one primary key and as far as I've read Cayenne cant generate more that one primary key per table. So I want the Postgres to do that work.
I have this table:
CREATE TABLE telefonocliente
(
cod_cliente integer NOT NULL DEFAULT currval('cliente_serial'::regclass),
cod_telefono integer NOT NULL DEFAULT nextval('telefonocliente_serial'::regclass),
fijo integer,
CONSTRAINT telefonocliente_pkey PRIMARY KEY (cod_cliente, cod_telefono)
)
WITH (
OIDS=FALSE
);
TelefonoCliente telefono = context.newObject(TelefonoCliente.class);
telefono.setFijo(4999000);
context.commitChanges();
and this is the error I get:
INFO: --- transaction started.
19/11/2013 22:46:17 org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy processSchemaUpdate
INFO: Full or partial schema detected, skipping tables creation
19/11/2013 22:46:17 org.apache.cayenne.log.CommonsJdbcEventLogger logQuery
INFO: SELECT nextval('pk_telefonocliente')
Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: [v.3.2M1 Jul 07 2013 16:23:58] Commit Exception
at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:759)
at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:676)
at org.example.cayenne.Main.main(Main.java:45)
Caused by: org.postgresql.util.PSQLException: ERROR: no existe la relaci?n ≪pk_telefonocliente≫
Position: 16
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at org.apache.cayenne.dba.postgres.PostgresPkGenerator.longPkFromDatabase(PostgresPkGenerator.java:79)
at org.apache.cayenne.dba.JdbcPkGenerator.generatePk(JdbcPkGenerator.java:272)
at org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainInsertBucket.java:171)
at org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(DataDomainInsertBucket.java:76)
at org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyncBucket.java:78)
at org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlushAction.java:188)
at org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:144)
at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:685)
at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:651)
at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:712)
at org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:648)
at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync(DataDomain.java:852)
at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:629)
at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:727)
... 2 more
I've been trying the suggestions on Cayenne tutorial "generated columns", "primary key support" but I seems to always get some error.
INFO: SELECT nextval('pk_telefonocliente')
Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: [v.3.2M1 Jul 07 2013 16:23:58] Primary Key autogeneration only works for a single attribute.
I want to know how to solve this.
Thanks in advance
From your description in comments, out of 2 columns comprising the PK of 'telefonocliente', only one is truly independent - 'cod_telefono'. This will be what Cayenne will generate. In case of PosgreSQL, you will need the following sequence in DB for this to happen:
CREATE SEQUENCE pk_telefonocliente INCREMENT 20 START 200;
Now, where does the second PK 'cod_cliente' come from? Since it is also FK to another table, it means it is a "dependent" PK, and must come from a relationship. So first you need to map a many-to-one relationship between 'telefonocliente' and 'cliente'. Check "To Dep Pk" checkbox on the 'telefonocliente' side. Generate a matching ObjRelationship for your Java objects. Now you can use it in your code:
Cliente c = .. // get a hold of this object somehow
TelefonoCliente telefono = context.newObject(TelefonoCliente.class);
telefono.setFijo(4999000);
telefono.setCliente(c); // this line is what will populate 'cod_cliente' PK/FK
That should be it.
The primary key is allowed just to be one per a table! In your case you create a primary key on two columns, that is right, it is defined in an SQL standard and Postgres supports it well.
However there is a not in Cayenne documentation:
Cayenne only supports automatic PK generation for a single column per table.
see http://cayenne.apache.org/docs/3.0/primary-key-generation.html at the bottom of the page.
Probably they can fix it in a newer version or you can put a request to the Cayenne community.

Play Framework using Oracle Database - ORA-00942: table or view does not exist

I can't solve my problem with my local Oracle database.
I'm tryong to connect to my local Oracle database (Oracle Database 11g Express Edition)
Later on I will use JNDI to another Oracle Database, but I think this should still work.
Driver: ojdbc6.jar in /lib
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#localhost:1521:xe"
db.default.user="user"
db.default.pass="pass"
So I know I do connect to the database, but the error is that it says that the table does not exist. I'm not even creating or querying to a table (no model exists - but I've tried with having a model too, same error). Something seems to be wrong in the beginning and I don't know how to Debug this.
Error:
**java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist**
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:400)
oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:926)
oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:200)
oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:543)
oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:197)
oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:1213)
oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1492)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1710)
oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:2006)
oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:1709)
com.jolbox.bonecp.StatementHandle.executeQuery(StatementHandle.java:503)
play.api.db.evolutions.Evolutions$.executeQuery(Evolutions.scala:118)
play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:334)
play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:306)
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply$mcV$sp(Evolutions.scala:435)
play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:478)
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:434)
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:432)
scala.collection.immutable.List.foreach(List.scala:309)
play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:432)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:63)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:63)
scala.collection.immutable.List.foreach(List.scala:309)
play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:63)
play.api.Play$$anonfun$start$1.apply(Play.scala:63)
play.api.Play$$anonfun$start$1.apply(Play.scala:63)
When reading about it I've only found that I might not have permission to some table, but the thing is that I use the same login in Oracle SQL Developer and it works.
As nico_ekito wrote, you need to create this table manually.
This one works for me:
CREATE TABLE play_evolutions
(
id Number(10,0) Not Null Enable,
hash VARCHAR2(255 Byte),
applied_at Timestamp Not Null,
apply_script clob,
revert_script clob,
state Varchar2(255),
last_problem clob,
CONSTRAINT play_evolutions_pk PRIMARY KEY (id)
);
Try to manually create a play_evolutions table with the following columns (by adapting the types to the ones used by Oracle):
id int not null primary key, hash varchar(255) not null,
applied_at timestamp not null,
apply_script text,
revert_script text,
state varchar(255),
last_problem text
In conf/application.conf
Un-comment the following line:
evolutionplugin=disabled
This is if you don't need Evolutions (to track schema changes).

Resources