CREATE TABLE webform 
  ( nid int(10) unsigned not null,
    confirmation text,
    redirect_post int(1) unsigned not null default '0',
    email varchar(255),
    email_subject varchar(255),
    email_from varchar(255),
    primary key(nid));

CREATE TABLE webform_component 
  ( nid int(10) unsigned not null, 
    cid int(10) unsigned not null, 
    name varchar(128), 
    type varchar(16), 
    value varchar(128),
    extra text, 
    mandatory int(2) unsigned, 
    weight int(2),
    PRIMARY KEY(nid, cid));

CREATE TABLE webform_role_node 
  ( nid int(10) unsigned not null,
    rid int(10) unsigned not null,
    PRIMARY KEY(nid, rid));

CREATE TABLE webform_submitted_data
  ( nid int(10) unsigned NOT NULL default '0',
    sid int(10) unsigned NOT NULL default '0',
    cid int(10) unsigned NOT NULL default '0',
    no int(10) unsigned NOT NULL default '0',
    data longtext,
    PRIMARY KEY (nid,sid,cid,no));

CREATE TABLE webform_submissions 
  ( nid int(10) unsigned NOT NULL default '0', 
    sid int(10) unsigned NOT NULL default '0',
    submitted int(11)  NOT NULL default '0',
    PRIMARY KEY  (nid, sid));

-- Setting default variables
DELETE FROM variable WHERE name = 'webform_version';
INSERT INTO variable VALUES ('webform_version', 'a:2:{s:4:"text";s:5:"4.7.1";s:5:"build";i:471;}');
UPDATE system SET schema_version = 1 WHERE name = 'webform';
