Permalink
Browse files

[PostgreSQL] Changed sequences naming to conform to SERIAL type (#1906)

  • Loading branch information...
alongosz committed Feb 7, 2017
1 parent d8e7fff commit 2bda94087aa902e45b6cc3edde8e1870bde284e1
@@ -39,7 +39,7 @@ public function getAutoIncrementValue($table, $column)
*/
public function getSequenceName($table, $column)
{
return $table . '_s';
return sprintf('%s_%s_seq', $table, $column);
}
/**
@@ -1,92 +1,3 @@
DROP SEQUENCE IF EXISTS ezcobj_state_s;
CREATE SEQUENCE ezcobj_state_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcobj_state_group_s;
CREATE SEQUENCE ezcobj_state_group_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentclass_s;
CREATE SEQUENCE ezcontentclass_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentclass_attribute_s;
CREATE SEQUENCE ezcontentclass_attribute_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentclassgroup_s;
CREATE SEQUENCE ezcontentclassgroup_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentobject_s;
CREATE SEQUENCE ezcontentobject_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentobject_attribute_s;
CREATE SEQUENCE ezcontentobject_attribute_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentobject_link_s;
CREATE SEQUENCE ezcontentobject_link_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentobject_tree_s;
CREATE SEQUENCE ezcontentobject_tree_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezcontentobject_version_s;
CREATE SEQUENCE ezcontentobject_version_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS eznode_assignment_s;
CREATE SEQUENCE eznode_assignment_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezpolicy_s;
CREATE SEQUENCE ezpolicy_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezpolicy_limitation_s;
CREATE SEQUENCE ezpolicy_limitation_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezpolicy_limitation_value_s;
CREATE SEQUENCE ezpolicy_limitation_value_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezrole_s;
CREATE SEQUENCE ezrole_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezsearch_object_word_link_s;
CREATE SEQUENCE ezsearch_object_word_link_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezsearch_word_s;
CREATE SEQUENCE ezsearch_word_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezsection_s;
CREATE SEQUENCE ezsection_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezurl_s;
CREATE SEQUENCE ezurl_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezurlalias_s;
CREATE SEQUENCE ezurlalias_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezurlalias_ml_incr_s;
CREATE SEQUENCE ezurlalias_ml_incr_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezurlwildcard_s;
CREATE SEQUENCE ezurlwildcard_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezuser_accountkey_s;
CREATE SEQUENCE ezuser_accountkey_s
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;
DROP SEQUENCE IF EXISTS ezuser_role_s;
CREATE SEQUENCE ezuser_role_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezuser_accountkey_s;
CREATE SEQUENCE ezuser_accountkey_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezkeyword_s;
CREATE SEQUENCE ezkeyword_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezkeyword_attribute_link_s;
CREATE SEQUENCE ezkeyword_attribute_link_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP SEQUENCE IF EXISTS ezimagefile_s;
CREATE SEQUENCE ezimagefile_s START 1 INCREMENT 1 MAXVALUE 9223372036854775807 MINVALUE 1 CACHE 1;
DROP TABLE IF EXISTS ezbinaryfile;
CREATE TABLE ezbinaryfile (
contentobject_attribute_id integer DEFAULT 0 NOT NULL,
@@ -119,7 +30,7 @@ DROP TABLE IF EXISTS ezimagefile;
CREATE TABLE ezimagefile (
contentobject_attribute_id integer DEFAULT 0 NOT NULL,
filepath text NOT NULL,
id integer DEFAULT nextval('ezimagefile_s'::text) NOT NULL
id SERIAL
);
DROP TABLE IF EXISTS ezgmaplocation;
@@ -135,7 +46,7 @@ DROP TABLE IF EXISTS ezcobj_state;
CREATE TABLE ezcobj_state (
default_language_id bigint NOT NULL DEFAULT 0,
group_id integer NOT NULL DEFAULT 0,
id integer DEFAULT nextval('ezcobj_state_s'::text) NOT NULL,
id SERIAL,
identifier character varying(45) NOT NULL DEFAULT ''::character varying,
language_mask bigint NOT NULL DEFAULT 0,
priority integer NOT NULL DEFAULT 0
@@ -144,7 +55,7 @@ CREATE TABLE ezcobj_state (
DROP TABLE IF EXISTS ezcobj_state_group;
CREATE TABLE ezcobj_state_group (
default_language_id bigint NOT NULL DEFAULT 0,
id integer DEFAULT nextval('ezcobj_state_group_s'::text) NOT NULL,
id SERIAL,
identifier character varying(45) NOT NULL DEFAULT ''::character varying,
language_mask bigint NOT NULL DEFAULT 0
);
@@ -186,7 +97,7 @@ CREATE TABLE ezcontentclass (
contentobject_name character varying(255),
created integer DEFAULT 0 NOT NULL,
creator_id integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezcontentclass_s'::text) NOT NULL,
id SERIAL,
identifier character varying(50) DEFAULT ''::character varying NOT NULL,
initial_language_id bigint DEFAULT 0 NOT NULL,
is_container integer DEFAULT 0 NOT NULL,
@@ -221,7 +132,7 @@ CREATE TABLE ezcontentclass_attribute (
data_text4 character varying(255),
data_text5 text,
data_type_string character varying(50) DEFAULT ''::character varying NOT NULL,
id integer DEFAULT nextval('ezcontentclass_attribute_s'::text) NOT NULL,
id SERIAL,
identifier character varying(50) DEFAULT ''::character varying NOT NULL,
is_information_collector integer DEFAULT 0 NOT NULL,
is_required integer DEFAULT 0 NOT NULL,
@@ -254,7 +165,7 @@ DROP TABLE IF EXISTS ezcontentclassgroup;
CREATE TABLE ezcontentclassgroup (
created integer DEFAULT 0 NOT NULL,
creator_id integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezcontentclassgroup_s'::text) NOT NULL,
id SERIAL,
modified integer DEFAULT 0 NOT NULL,
modifier_id integer DEFAULT 0 NOT NULL,
name character varying(255)
@@ -264,7 +175,7 @@ DROP TABLE IF EXISTS ezcontentobject;
CREATE TABLE ezcontentobject (
contentclass_id integer DEFAULT 0 NOT NULL,
current_version integer,
id integer DEFAULT nextval('ezcontentobject_s'::text) NOT NULL,
id SERIAL,
initial_language_id bigint DEFAULT 0 NOT NULL,
language_mask bigint DEFAULT 0 NOT NULL,
modified integer DEFAULT 0 NOT NULL,
@@ -285,7 +196,7 @@ CREATE TABLE ezcontentobject_attribute (
data_int integer,
data_text text,
data_type_string character varying(50) DEFAULT ''::character varying,
id integer DEFAULT nextval('ezcontentobject_attribute_s'::text) NOT NULL,
id SERIAL,
language_code character varying(20) DEFAULT ''::character varying NOT NULL,
language_id bigint DEFAULT 0 NOT NULL,
sort_key_int integer DEFAULT 0 NOT NULL,
@@ -298,7 +209,7 @@ CREATE TABLE ezcontentobject_link (
contentclassattribute_id integer DEFAULT 0 NOT NULL,
from_contentobject_id integer DEFAULT 0 NOT NULL,
from_contentobject_version integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezcontentobject_link_s'::text) NOT NULL,
id SERIAL,
relation_type integer DEFAULT 1 NOT NULL,
to_contentobject_id integer DEFAULT 0 NOT NULL
);
@@ -342,7 +253,7 @@ CREATE TABLE ezcontentobject_tree (
is_invisible integer DEFAULT 0 NOT NULL,
main_node_id integer,
modified_subnode integer DEFAULT 0,
node_id integer DEFAULT nextval('ezcontentobject_tree_s'::text) NOT NULL,
node_id SERIAL,
parent_node_id integer DEFAULT 0 NOT NULL,
path_identification_string text,
path_string character varying(255) DEFAULT ''::character varying NOT NULL,
@@ -357,7 +268,7 @@ CREATE TABLE ezcontentobject_version (
contentobject_id integer,
created integer DEFAULT 0 NOT NULL,
creator_id integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezcontentobject_version_s'::text) NOT NULL,
id SERIAL,
initial_language_id bigint DEFAULT 0 NOT NULL,
language_mask bigint DEFAULT 0 NOT NULL,
modified integer DEFAULT 0 NOT NULL,
@@ -372,7 +283,7 @@ CREATE TABLE eznode_assignment (
contentobject_id integer,
contentobject_version integer,
from_node_id integer DEFAULT 0,
id integer DEFAULT nextval('eznode_assignment_s'::text) NOT NULL,
id SERIAL,
is_main integer DEFAULT 0 NOT NULL,
op_code integer DEFAULT 0 NOT NULL,
parent_node integer,
@@ -387,29 +298,29 @@ CREATE TABLE eznode_assignment (
DROP TABLE IF EXISTS ezpolicy;
CREATE TABLE ezpolicy (
function_name character varying(255),
id integer DEFAULT nextval('ezpolicy_s'::text) NOT NULL,
id SERIAL,
module_name character varying(255),
original_id integer DEFAULT 0 NOT NULL,
role_id integer
);
DROP TABLE IF EXISTS ezpolicy_limitation;
CREATE TABLE ezpolicy_limitation (
id integer DEFAULT nextval('ezpolicy_limitation_s'::text) NOT NULL,
id SERIAL,
identifier character varying(255) DEFAULT ''::character varying NOT NULL,
policy_id integer
);
DROP TABLE IF EXISTS ezpolicy_limitation_value;
CREATE TABLE ezpolicy_limitation_value (
id integer DEFAULT nextval('ezpolicy_limitation_value_s'::text) NOT NULL,
id SERIAL,
limitation_id integer,
value character varying(255)
);
DROP TABLE IF EXISTS ezrole;
CREATE TABLE ezrole (
id integer DEFAULT nextval('ezrole_s'::text) NOT NULL,
id SERIAL,
is_new integer DEFAULT 0 NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL,
value character(1),
@@ -422,7 +333,7 @@ CREATE TABLE ezsearch_object_word_link (
contentclass_id integer DEFAULT 0 NOT NULL,
contentobject_id integer DEFAULT 0 NOT NULL,
frequency double precision DEFAULT 0::double precision NOT NULL,
id integer DEFAULT nextval('ezsearch_object_word_link_s'::text) NOT NULL,
id SERIAL,
identifier character varying(255) DEFAULT ''::character varying NOT NULL,
integer_value integer DEFAULT 0 NOT NULL,
next_word_id integer DEFAULT 0 NOT NULL,
@@ -435,14 +346,14 @@ CREATE TABLE ezsearch_object_word_link (
DROP TABLE IF EXISTS ezsearch_word;
CREATE TABLE ezsearch_word (
id integer DEFAULT nextval('ezsearch_word_s'::text) NOT NULL,
id SERIAL,
object_count integer DEFAULT 0 NOT NULL,
word character varying(150)
);
DROP TABLE IF EXISTS ezsection;
CREATE TABLE ezsection (
id integer DEFAULT nextval('ezsection_s'::text) NOT NULL,
id SERIAL,
identifier character varying(255),
locale character varying(255),
name character varying(255),
@@ -452,7 +363,7 @@ CREATE TABLE ezsection (
DROP TABLE IF EXISTS ezurl;
CREATE TABLE ezurl (
created integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezurl_s'::text) NOT NULL,
id SERIAL,
is_valid integer DEFAULT 1 NOT NULL,
last_checked integer DEFAULT 0 NOT NULL,
modified integer DEFAULT 0 NOT NULL,
@@ -471,7 +382,7 @@ DROP TABLE IF EXISTS ezurlalias;
CREATE TABLE ezurlalias (
destination_url text NOT NULL,
forward_to_id integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezurlalias_s'::text) NOT NULL,
id SERIAL,
is_imported integer DEFAULT 0 NOT NULL,
is_internal integer DEFAULT 1 NOT NULL,
is_wildcard integer DEFAULT 0 NOT NULL,
@@ -496,13 +407,13 @@ CREATE TABLE ezurlalias_ml (
DROP TABLE IF EXISTS ezurlalias_ml_incr;
CREATE TABLE ezurlalias_ml_incr (
id integer DEFAULT nextval('ezurlalias_ml_incr_s'::text) NOT NULL
id SERIAL
);
DROP TABLE IF EXISTS ezurlwildcard;
CREATE TABLE ezurlwildcard (
destination_url text NOT NULL,
id integer DEFAULT nextval('ezurlwildcard_s'::text) NOT NULL,
id SERIAL,
source_url text NOT NULL,
"type" integer DEFAULT 0 NOT NULL
);
@@ -516,18 +427,10 @@ CREATE TABLE ezuser (
password_hash_type integer DEFAULT 1 NOT NULL
);
DROP TABLE IF EXISTS ezuser_accountkey;
CREATE TABLE ezuser_accountkey (
hash_key character varying(32) DEFAULT ''::character varying NOT NULL,
id integer DEFAULT nextval('ezuser_accountkey_s'::text) NOT NULL,
"time" integer DEFAULT 0 NOT NULL,
user_id integer DEFAULT 0 NOT NULL
);
DROP TABLE IF EXISTS ezuser_role;
CREATE TABLE ezuser_role (
contentobject_id integer,
id integer DEFAULT nextval('ezuser_role_s'::text) NOT NULL,
id SERIAL,
limit_identifier character varying(255) DEFAULT ''::character varying,
limit_value character varying(255) DEFAULT ''::character varying,
role_id integer
@@ -543,7 +446,7 @@ CREATE TABLE ezuser_setting (
DROP TABLE IF EXISTS ezuser_accountkey;
CREATE TABLE ezuser_accountkey (
hash_key character varying(32) DEFAULT '' NOT NULL,
id integer DEFAULT nextval('ezuser_accountkey_s'::text) NOT NULL,
id SERIAL,
time integer DEFAULT 0 NOT NULL,
user_id integer DEFAULT 0 NOT NULL
);
@@ -560,13 +463,13 @@ CREATE TABLE ezuservisit (
DROP TABLE IF EXISTS ezkeyword;
CREATE TABLE ezkeyword (
class_id integer DEFAULT 0 NOT NULL,
id integer DEFAULT nextval('ezkeyword_s'::text) NOT NULL,
id SERIAL,
keyword character varying(255) DEFAULT NULL
);
DROP TABLE IF EXISTS ezkeyword_attribute_link;
CREATE TABLE ezkeyword_attribute_link (
id integer DEFAULT nextval('ezkeyword_attribute_link_s'::text) NOT NULL,
id SERIAL,
keyword_id integer DEFAULT 0 NOT NULL,
objectattribute_id integer DEFAULT 0 NOT NULL
);
Oops, something went wrong.

3 comments on commit 2bda940

@wizhippo

This comment has been minimized.

Show comment
Hide comment
@wizhippo

wizhippo Jan 3, 2018

Contributor

Is there going to be any migration script for this as existing sequences need to be updated to the new naming?
EDIT: also will this cause any issue with legacy?

Contributor

wizhippo replied Jan 3, 2018

Is there going to be any migration script for this as existing sequences need to be updated to the new naming?
EDIT: also will this cause any issue with legacy?

@alongosz

This comment has been minimized.

Show comment
Hide comment
@alongosz

alongosz Jan 4, 2018

Member

Is there going to be any migration script for this as existing sequences need to be updated to the new naming?

@wizhippo I knew I forgot something... I'll try to make it soon.

also will this cause any issue with legacy?

As for Legacy, it depends if any other code beside eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler\PostgresConnectionHandler generates sequence name. I'm not that familiar with Legacy stack.
// cc @andrerom

Member

alongosz replied Jan 4, 2018

Is there going to be any migration script for this as existing sequences need to be updated to the new naming?

@wizhippo I knew I forgot something... I'll try to make it soon.

also will this cause any issue with legacy?

As for Legacy, it depends if any other code beside eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler\PostgresConnectionHandler generates sequence name. I'm not that familiar with Legacy stack.
// cc @andrerom

@andrerom

This comment has been minimized.

Show comment
Hide comment
@andrerom

andrerom Jan 4, 2018

Member

As for Legacy, it depends if any other code beside eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler\PostgresConnectionHandler generates sequence name. I'm not that familiar with Legacy stack.

@wizhippo this was merged early in the life of 7.0 branch before we went ahead and supported legacy bridge to simplify migration for customers. We'll look into what to do here, might be we will then have to revert this and re-introduced in future enhanced storage engine later this year.

Member

andrerom replied Jan 4, 2018

As for Legacy, it depends if any other code beside eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler\PostgresConnectionHandler generates sequence name. I'm not that familiar with Legacy stack.

@wizhippo this was merged early in the life of 7.0 branch before we went ahead and supported legacy bridge to simplify migration for customers. We'll look into what to do here, might be we will then have to revert this and re-introduced in future enhanced storage engine later this year.

Please sign in to comment.