CREATE TABLE partner_bank
(
  kod serial NOT NULL,
  partner_kod integer,
  bank_neve character varying(30) DEFAULT '',
  bankszamla character varying(30),
  iban character varying(40) DEFAULT '',
  swift character varying(15) DEFAULT '',
  m_userid character varying(20) DEFAULT '',
  m_date date DEFAULT '2005-01-01',
  m_time time without time zone DEFAULT '00:00:00',
  c_userid character varying(20) DEFAULT '',
  c_date date DEFAULT '2005-01-01',
  c_time time without time zone DEFAULT '00:00:00',
  alapertelmezetett smallint DEFAULT 0,
  CONSTRAINT partner_bank_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE INDEX partner_bank_i1
  ON partner_bank
  USING btree
  (partner_kod);

INSERT INTO partner_bank (partner_kod, bank_neve, bankszamla, iban, swift) (SELECT kod, bank_neve1, bankszamla1, iban1, swift1 FROM partner WHERE bankszamla1 <> '' AND (kod, bank_neve1, bankszamla1, iban1, swift1) NOT IN (SELECT partner_kod, bank_neve, bankszamla, iban, swift FROM partner_bank));
INSERT INTO partner_bank (partner_kod, bank_neve, bankszamla, iban, swift) (SELECT kod, bank_neve2, bankszamla2, iban2, swift2 FROM partner WHERE bankszamla2 <> '' AND (kod, bank_neve2, bankszamla2, iban2, swift2) NOT IN (SELECT partner_kod, bank_neve, bankszamla, iban, swift FROM partner_bank));

ALTER TABLE partner_emailtar ADD COLUMN m_userid character varying(20);
ALTER TABLE partner_emailtar ALTER COLUMN m_userid SET STORAGE EXTENDED;
ALTER TABLE partner_emailtar ALTER COLUMN m_userid SET DEFAULT '';
ALTER TABLE partner_emailtar ADD COLUMN m_date date;
ALTER TABLE partner_emailtar ALTER COLUMN m_date SET STORAGE PLAIN;
ALTER TABLE partner_emailtar ALTER COLUMN m_date SET DEFAULT '2005-01-01';
ALTER TABLE partner_emailtar ADD COLUMN m_time time without time zone;
ALTER TABLE partner_emailtar ALTER COLUMN m_time SET STORAGE PLAIN;
ALTER TABLE partner_emailtar ALTER COLUMN m_time SET DEFAULT '00:00:00';
ALTER TABLE partner_emailtar ADD COLUMN c_userid character varying(20);
ALTER TABLE partner_emailtar ALTER COLUMN c_userid SET STORAGE EXTENDED;
ALTER TABLE partner_emailtar ALTER COLUMN c_userid SET DEFAULT '';
ALTER TABLE partner_emailtar ADD COLUMN c_date date;
ALTER TABLE partner_emailtar ALTER COLUMN c_date SET STORAGE PLAIN;
ALTER TABLE partner_emailtar ALTER COLUMN c_date SET DEFAULT '2005-01-01';
ALTER TABLE partner_emailtar ADD COLUMN c_time time without time zone;
ALTER TABLE partner_emailtar ALTER COLUMN c_time SET STORAGE PLAIN;
ALTER TABLE partner_emailtar ALTER COLUMN c_time SET DEFAULT '00:00:00';

ALTER TABLE szallitoi_szamlak ADD COLUMN partner_bank integer DEFAULT 0;
