use 1104;
delete from customers where deleted = 1;
delete from nodes where ownerid not in (select id from
customers);
delete from cashimport where customerid not in (select id
from customers);
delete from customercontacts where customerid not in (select
id from customers);
insert into lmsgit.customers (id, lastname, name, status,
email, address, zip, city, ten, ssn, regon, rbe, icn, info,
notes, creationdate, moddate, creatorid, modid, deleted,
message, pin) (select id, lastname, name, status, email,
address, zip, city, ten, ssn, regon, rbe, icn, info, notes,
creationdate, moddate, creatorid, modid, deleted, message,
pin from customers);
insert into lmsgit.customercontacts (id, customerid, name,
phone) (select id, customerid, name, phone from
customercontacts);
insert into lmsgit.hosts (select * from hosts);
insert into lmsgit.daemoninstances (select * from
daemoninstances);
insert into lmsgit.daemonconfig (select * from
daemonconfig);
insert into lmsgit.networks (id, name, address, mask,
gateway, interface) (select id, name, address, mask,
gateway, interface);
insert into lmsgit.nodes (id, name, ipaddr, ipaddr_pub,
ownerid, creationdate, moddate, access, warning, location,
netid) (select
nodes.id,
nodes.name,
ipaddr, ipaddr_pub, ownerid, creationdate, moddate, access,
warning, location,
networks.id from nodes left
join networks on (ipaddr & inet_aton(networks.mask) =
networks.address) and
networks.id is not null);
insert into lmsgit.macs (mac, nodeid) (select mac, id from
nodes);
insert into lmsgit.tariffs (id, name, value, taxid, upceil,
downceil) (select id, name, value, taxid, upceil, downceil
from tariffs);
insert into lmsgit.assignments (id, tariffid, customerid,
period, at, datefrom, dateto, invoice, paytype) (select id,
tariffid, customerid, period, at, datefrom, dateto, invoice,
1 from assignments);
insert into lmsgit.nodeassignments (assignmentid, nodeid)
(select
a.id,
n.nodeid from assignments a join nodeassignments n ON
a.id =
n.assignmentid);
insert into lmsgit.cashimport (id, date, value, customer,
description, customerid, hash, closed) (select * from
cashimport);
insert into lmsgit.cash (id, time, type, userid, value,
taxid, customerid, comment, docid, itemid) (select id, time,
type, userid, value, taxid, customerid, comment, docid,
itemid from cash);
insert into lmsgit.documents (id, type, number,
numberplanid, extnumber, cdate, customerid, userid, name,
address, zip, city, ten, ssn, paytime, paytype, closed,
reference, reason) (select id, type, number, numberplanid,
extnumber, cdate, customerid, userid, name, address, zip,
city, ten, ssn, paytime, (CASE paytype WHEN 'TRANSFER' THEN
2 WHEN 'PRZELEW' THEN 2 WHEN 'CASH' then 1 WHEN 'Gotówka'
THEN 1 END), closed, reference, reason from documents);
insert into lmsgit.documentcontents (select * from
documentcontents);
insert into lmsgit.domains (id, ownerid, name, description)
(select id, ownerid, name, description from domains);
insert into lmsgit.numberplans (select * from numberplans);
insert into lmsgit.passwd (id, ownerid, login, `password`,
lastlogin, uid, home, `type`, expdate, domainid, quota_sh,
quota_mail, quota_www, quota_ftp, quota_sql, realname,
createtime) (select id, ownerid, login, `password`,
lastlogin, uid, home, `type`, expdate, domainid, quota_sh,
quota_mail, quota_www, quota_ftp, quota_sql, realname,
createtime from passwd);
insert into lmsgit.taxes (select * from taxes);
insert into lmsgit.invoicecontents (docid, itemid, value,
taxid, prodid, content, count, description, tariffid)
(select docid, itemid, value, taxid, prodid, content, count,
description, tariffid from invoicecontents);
####
i chyba voila.
Jakby ktoś miał coś do dodania, to smiało.