Jean-Francois Leveque

Migration éditeur et adaptation import.sql

create table Country (
countryId int(11) NOT NULL AUTO_INCREMENT,
countryName varchar(100) DEFAULT NULL,
PRIMARY KEY ('countryId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into Country (countryId, countryName)
select ID_PAYS, LIB_PAYS from pays;
show create table Country;
\ No newline at end of file
create table Publisher (
publisherId int(11) NOT NULL AUTO_INCREMENT,
validatedVersion int(11),
PRIMARY KEY ('publisherId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into Publisher (publisherId, validatedVersion)
select ID_EDITEUR, ID_EDITEUR from editeur;
create table PublisherVersion (
publisherVersionId int(11) NOT NULL AUTO_INCREMENT,
publisher_publisherId int(11) NOT NULL,
publisherName varchar(50) NOT NULL,
publisherStreetAddress varchar(300),
publisherPostalCode varchar(15),
publisherPostOfficeBoxNumber varchar(50),
publisherAddressRegion varchar(50),
publisherAddressLocality varchar(50),
publisherAddressCountry_countryId int(11),
publisherTelephone varchar(25),
publisherEmail varchar(50),
publisherURL varchar(100),
publisherActive TINYINT(1),
publisherHistory longtext,
publisherVersionAuthor_userId int(11),
publisherVersionDatetime DATETIME,
PRIMARY KEY ('publisherVersionId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into PublisherVersion (publisherVersionId, publisher_publisherId,
publisherName, publisherStreetAddress, publisherPostalCode,
publisherPostOfficeBoxNumber, publisherAddressRegion,
publisherAddressLocality, publisherAddressCountry_countryId,
publisherTelephone, publisherEmail, publisherURL, publisherActive,
publisherHistory, publisherVersionAuthor_userId, publisherVersionDatetime)
select ID_EDITEUR, ID_EDITEUR, NOM_EDITEUR, ADR_EDITEUR, CP_EDITEUR, NULL,
NULL, VILLE, countryId, TEL_EDITEUR, EMAIL_EDITEUR, URL_EDITEUR, NULL,
HISTORIQUE, ID_UTILISATEUR, DATE_ACTION
from editeur e
left join Country on countryName = e.PAYS
join journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from journal j2
where j2.ID_JOURNALISABLE = e.ID_EDITEUR)
union
select ID_EDITEUR, ID_EDITEUR, NOM_EDITEUR, ADR_EDITEUR, CP_EDITEUR, NULL,
NULL, VILLE, countryId, TEL_EDITEUR, EMAIL_EDITEUR, URL_EDITEUR, NULL,
HISTORIQUE, null, null
from editeur e
left join Country on countryName = e.PAYS
where ID_EDITEUR not in (select distinct ID_JOURNALISABLE from journal)
;
create table PublisherAction (
publisherActionId int(11) NOT NULL AUTO_INCREMENT,
ActionType TINYINT UNSIGNED NOT NULL,
publisherActionAuthor_userId int(11) NOT NULL,
publisherVersion_publisherVersionId int(11) NOT NULL,
publisherActionDatetime DATETIME,
publisher_publisherId int(11) NOT NULL,
PRIMARY KEY ('publisherActionId')
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into PublisherAction (ActionType, publisherActionAuthor_userId,
publisherVersion_publisherVersionId, publisherActionDatetime,
publisher_publisherId)
select 0, ID_UTILISATEUR, ID_EDITEUR, DATE_ACTION, ID_EDITEUR
from editeur e
join journal j on j.ID_JOURNALISABLE = e.ID_EDITEUR
where j.DATE_ACTION = (select max(DATE_ACTION) from journal j2
where j2.ID_JOURNALISABLE = e.ID_EDITEUR)
;
show create table Publisher;
show create table PublisherVersion;
show create table PublisherAction;
\ No newline at end of file
source normalisePays.sql
source creeV3Country.sql
source creeV3Publisher+Version+Action.sql
\ No newline at end of file
-- PREPARATION TABLE editeur
-- Standardisation des valeurs de PAYS dans editeur
update editeur set PAYS='Allemagne' where PAYS in ('Deutschland');
update editeur set PAYS='Australie' where PAYS in ('Australia');
update editeur set PAYS='Espagne' where PAYS in ('España');
update editeur set PAYS='Pologne' where PAYS in ('Polska');
update editeur set PAYS='Royaume-Uni' where PAYS in ('United Kingdom', 'Royaume Uni', 'Grande-Bretagne', 'United Kingdoms', 'Royaumes Unis', 'Angleterre', 'UK');
update editeur set PAYS='États-Unis' where PAYS in ('USA', 'Etats Unis', 'Etats-Unis d\'Amérique', 'Etats Unis d\'Amérique', 'Caroline du Sud');
update editeur set PAYS='République thèque' where PAYS in ('Ceska Republika');
update editeur set PAYS='Finlande' where PAYS in ('Suomi / Finlande');
update editeur set PAYS='Suède' where PAYS in ('Sverige / Suède');
update editeur set PAYS='Italie' where PAYS in ('Italia');
update editeur set PAYS='Grèce' where PAYS in ('Ellada / Grèce', 'Ellada / Grèce');
update editeur set PAYS='Brésil' where PAYS in ('Brasil/Brésil', 'Brasil', 'Brasilia');
update editeur set PAYS='Nouvelle-Zélande' where PAYS in ('New Zealand', 'New-Zeland');
-- Suppression d'un pays imaginaire
-- http://www.legrog.org/editeurs/hugin-munin
update editeur set PAYS=NULL where PAYS='France / Canada';
-- PREPARATION TABLE pays
-- Ajouts dans la table pays pour intégration
insert into pays (LIB_PAYS) values ('République thèque');
insert into pays (LIB_PAYS) values ('Finlande');
insert into pays (LIB_PAYS) values ('Suède');
insert into pays (LIB_PAYS) values ('Italie');
insert into pays (LIB_PAYS) values ('Grèce');
insert into pays (LIB_PAYS) values ('Brésil');
insert into pays (LIB_PAYS) values ('Nouvelle-Zélande');
insert into pays (LIB_PAYS) values ('Japon');
insert into pays (LIB_PAYS) values ('Corée du Sud');
insert into pays (LIB_PAYS) values ('Pays-Bas');
insert into pays (LIB_PAYS) values ('Hongrie');
update pays set LIB_PAYS='États-Unis' where LIB_PAYS='USA';
-- CONTROLE MATCHING
select ID_EDITEUR from editeur
where PAYS is not null
and PAYS not in (select LIB_PAYS from pays);
\ No newline at end of file
-- INSERT avec identifiants car GenerationType.AUTO a du être changé en GenerationType.IDENTITY (2016-11-21)
//INSERT INTO ActionType (actionTypeId, actionTypeName) VALUES (1, 'Validate');
INSERT INTO Country (countryId, countryName) VALUES
(1, 'France'),
(2, 'Suisse'),
(3, 'Belgique'),
(4, 'Canada'),
(5, 'États-Unis d''Amérique'),
(6, 'Australie'),
(7, 'Espagne'),
(8, 'Portugal'),
(9, 'Royaume-Uni'),
(10, 'Allemagne'),
(11, 'Pologne'),
(12, 'Italie');
-- INSERT INTO Country (countryId, countryName) VALUES
-- (1, 'France'),
-- (2, 'Suisse'),
-- (3, 'Belgique'),
-- (4, 'Canada'),
-- (5, 'États-Unis d''Amérique'),
-- (6, 'Australie'),
-- (7, 'Espagne'),
-- (8, 'Portugal'),
-- (9, 'Royaume-Uni'),
-- (10, 'Allemagne'),
-- (11, 'Pologne'),
-- (12, 'Italie');
INSERT INTO Person (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible,
criticProvider) VALUES
(1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE),
(2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE),
(3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE),
(4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE),
(5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE),
(1, '1', null, '1f', '1l', '1n', '1@raza.org', TRUE, TRUE, TRUE, TRUE),
(2, '2', null, '2f', '2l', '2n', '2@raza.org', TRUE, FALSE, TRUE, TRUE),
(3, '3', null, '3f', '3l', '3n', '3@raza.org', TRUE, FALSE, TRUE, TRUE),
(4, '4', null, '4f', '4l', '4n', '4@raza.org', TRUE, FALSE, TRUE, TRUE),
(5, '5', null, '5f', '5l', '5n', '5@raza.org', TRUE, FALSE, TRUE, TRUE),
(8, '8', null, '8f', '8l', '8n', '8@raza.org', TRUE, FALSE, TRUE, TRUE),
(9, '9', null, '9f', '9l', '9n', '9@raza.org', TRUE, FALSE, TRUE, TRUE),
(10, '10', null, '10f', '10l', '10n', '10@raza.org', TRUE, FALSE, TRUE, TRUE),
(11, '11', null, '11f', '11l', '11n', '11@raza.org', TRUE, FALSE, TRUE, TRUE),
(12, '12', null, '12f', '12l', '12n', '12@raza.org', TRUE, TRUE, TRUE, TRUE),
(13, '13', null, '13f', '13l', '13n', '13@raza.org', TRUE, FALSE, TRUE, TRUE),
(17, '17', null, '17f', '17l', '17n', '17@raza.org', TRUE, FALSE, TRUE, TRUE),
(21, '21', null, '21f', '21l', '21n', '21@raza.org', TRUE, FALSE, TRUE, TRUE),
(22, '22', null, '22f', '22l', '22n', '22@raza.org', TRUE, TRUE, TRUE, TRUE),
(43, '43', null, '43f', '43l', '43n', '43@raza.org', TRUE, TRUE, TRUE, TRUE),
(48, '48', null, '48f', '48l', '48n', '48@raza.org', TRUE, FALSE, TRUE, TRUE),
(57, '57', null, '57f', '57l', '57n', '57@raza.org', TRUE, TRUE, TRUE, TRUE),
(109, '109', null, '109f', '109l', '109n', '109@raza.org', TRUE, FALSE, TRUE, TRUE),
(111, '111', null, '111f', '111l', '111n', '111@raza.org', TRUE, TRUE, TRUE, TRUE),
(127, '127', null, '127f', '127l', '127n', '127@raza.org', TRUE, TRUE, TRUE, TRUE),
(170, '170', null, '170f', '170l', '170n', '170@raza.org', TRUE, FALSE, TRUE, TRUE),
(185, '185', null, '185f', '185l', '185n', '185@raza.org', TRUE, FALSE, TRUE, TRUE),
(254, '254', null, '254f', '254l', '254n', '254@raza.org', TRUE, FALSE, TRUE, TRUE),
(311, '311', null, '311f', '311l', '311n', '311@raza.org', TRUE, FALSE, TRUE, TRUE),
(509, '509', null, '509f', '509l', '509n', '509@raza.org', TRUE, FALSE, TRUE, TRUE),
(1017, '1017', null, '1017f', '1017l', '1017n', '1017@raza.org', TRUE, TRUE, TRUE, TRUE),
(1028, '1028', null, '1028f', '1028l', '1028n', '1028@raza.org', TRUE, FALSE, TRUE, TRUE),
(1152, '1152', null, '1152f', '1152l', '1152n', '1152@raza.org', TRUE, FALSE, TRUE, TRUE),
(2316, '2316', null, '2316f', '2316l', '2316n', '2316@raza.org', TRUE, FALSE, TRUE, TRUE),
(2374, '2374', null, '2374f', '2374l', '2374n', '2374@raza.org', TRUE, FALSE, TRUE, TRUE),
(3362, '3362', null, '3362f', '3362l', '3362n', '3362@raza.org', TRUE, TRUE, TRUE, TRUE),
(3431, '3431', null, '3431f', '3431l', '3431n', '3431@raza.org', TRUE, FALSE, TRUE, TRUE),
(6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE);
INSERT INTO Publisher (publisherId) VALUES (1), (2), (3), (4);
-- INSERT INTO Publisher (publisherId) VALUES (1), (2), (3), (4);
INSERT INTO PublisherVersion (publisherVersionId, publisher_publisherId, publisherName, publisherStreetAddress,
publisherPostalCode, publisherPostOfficeBoxNumber, publisherAddressRegion,
publisherAddressLocality, publisherAddressCountry_countryId, publisherTelephone,
publisherEmail, publisherURL, publisherActive, publisherHistory,
publisherVersionAuthor_userId, publisherVersionDatetime) VALUES
(1, 1, 'GRôG', '', '', '', '', '', 1, '', 'passerelle@legrog.org', 'www.legrog.org', TRUE, 'Ouvert…', 1, {ts '2000-05-08 00:00:47'}),
(2, 2, 'Rôliste TV', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'www.rolistetv.com', TRUE, 'Ouvert…', 3, {ts '2010-05-20 08:43:16'}),
(3, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', TRUE, 'Ouvert…', 1, {ts '2000-01-01 00:02:33'}),
(4, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', FALSE, '… en 2015', 2, {ts '2015-01-01 00:05:22'}),
(5, 4, 'Archmagus', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'archimage.net', TRUE, 'Ouvert…', 4, {ts '2016-10-14 10:56:03'});
UPDATE Publisher SET validatedVersion_publisherVersionId = 1 WHERE publisherId = 1;
UPDATE Publisher SET validatedVersion_publisherVersionId = 2 WHERE publisherId = 2;
UPDATE Publisher SET validatedVersion_publisherVersionId = 4 WHERE publisherId = 3;
-- INSERT INTO PublisherVersion (publisherVersionId, publisher_publisherId, publisherName, publisherStreetAddress,
-- publisherPostalCode, publisherPostOfficeBoxNumber, publisherAddressRegion,
-- publisherAddressLocality, publisherAddressCountry_countryId, publisherTelephone,
-- publisherEmail, publisherURL, publisherActive, publisherHistory,
-- publisherVersionAuthor_userId, publisherVersionDatetime) VALUES
-- (1, 1, 'GRôG', '', '', '', '', '', 1, '', 'passerelle@legrog.org', 'www.legrog.org', TRUE, 'Ouvert…', 1, {ts '2000-05-08 00:00:47'}),
-- (2, 2, 'Rôliste TV', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'www.rolistetv.com', TRUE, 'Ouvert…', 3, {ts '2010-05-20 08:43:16'}),
-- (3, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', TRUE, 'Ouvert…', 1, {ts '2000-01-01 00:02:33'}),
-- (4, 3, 'La Vouivre', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'la-vouivre.com', FALSE, '… en 2015', 2, {ts '2015-01-01 00:05:22'}),
-- (5, 4, 'Archmagus', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'archimage.net', TRUE, 'Ouvert…', 4, {ts '2016-10-14 10:56:03'});
-- UPDATE Publisher SET validatedVersion_publisherVersionId = 1 WHERE publisherId = 1;
-- UPDATE Publisher SET validatedVersion_publisherVersionId = 2 WHERE publisherId = 2;
-- UPDATE Publisher SET validatedVersion_publisherVersionId = 4 WHERE publisherId = 3;
INSERT INTO PublisherAction (publisherActionId, actionType, publisherActionAuthor_userId,
publisherVersion_publisherVersionId, publisherActionDatetime, publisher_publisherId) VALUES
(1, 0, 2, 1, {ts '2000-05-08 12:00:28'}, 1),
(2, 0, 1, 2, {ts '2010-06-20 14:27:35'}, 2),
(3, 0, 1, 4, {ts '2015-01-01 16:18:17'}, 3);
-- INSERT INTO PublisherAction (publisherActionId, actionType, publisherActionAuthor_userId,
-- publisherVersion_publisherVersionId, publisherActionDatetime, publisher_publisherId) VALUES
-- (1, 0, 2, 1, {ts '2000-05-08 12:00:28'}, 1),
-- (2, 0, 1, 2, {ts '2010-06-20 14:27:35'}, 2),
-- (3, 0, 1, 4, {ts '2015-01-01 16:18:17'}, 3);
INSERT INTO UserRole (userRoleId, rolename, visible) VALUES
(1, 'VISITEUR', TRUE),
......