   `propagates` tinyint(1) unsigned NOT NULL DEFAULT '0',
   `autocomplete` tinyint(1) unsigned NOT NULL DEFAULT '0',
   `classifying_entity_definition_keyname` varchar(100) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
-  `created` datetime DEFAULT NULL,
-  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `changed` datetime DEFAULT NULL,
-  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `deleted` datetime DEFAULT NULL,
-  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `gae_key` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
+  `old_id` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
   PRIMARY KEY (`keyname`),
-  UNIQUE KEY `gae_key` (`gae_key`),
+  UNIQUE KEY `keyname` (`keyname`),
+  UNIQUE KEY `old_id` (`old_id`),
   KEY `ordinal` (`ordinal`),
-  KEY `dataproperty` (`dataproperty`),
   KEY `entity_definition_keyname` (`entity_definition_keyname`),
   KEY `relationship_definition_keyname` (`relationship_definition_keyname`),
   KEY `classifying_entity_definition_keyname` (`classifying_entity_definition_keyname`),
-  CONSTRAINT `pd_fk_ed` FOREIGN KEY (`entity_definition_keyname`) REFERENCES `entity_definition` (`keyname`),
-  CONSTRAINT `pd_fk_rd` FOREIGN KEY (`relationship_definition_keyname`) REFERENCES `relationship_definition` (`keyname`),
-  CONSTRAINT `pd_fk_ced` FOREIGN KEY (`classifying_entity_definition_keyname`) REFERENCES `entity_definition` (`keyname`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;
-
-CREATE TABLE `entity` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `entity_definition_keyname` varchar(25) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
-  `public` tinyint(1) unsigned NOT NULL DEFAULT '0',
-  `created` datetime DEFAULT NULL,
-  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `changed` datetime DEFAULT NULL,
-  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `deleted` datetime DEFAULT NULL,
-  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
-  `gae_key` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `gae_key` (`gae_key`),
-  KEY `public` (`public`),
-  KEY `entity_definition_keyname` (`entity_definition_keyname`),
-  CONSTRAINT `e_fk_ed` FOREIGN KEY (`entity_definition_keyname`) REFERENCES `entity_definition` (`keyname`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;
-
+  CONSTRAINT `pd_fk_ced` FOREIGN KEY (`classifying_entity_definition_keyname`) REFERENCES `entity_definition` (`keyname`) ON UPDATE CASCADE,
+  CONSTRAINT `pd_fk_ed` FOREIGN KEY (`entity_definition_keyname`) REFERENCES `entity_definition` (`keyname`) ON UPDATE CASCADE,
+  CONSTRAINT `pd_fk_rd` FOREIGN KEY (`relationship_definition_keyname`) REFERENCES `relationship_definition` (`keyname`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;
+
+-- Create syntax for TABLE 'relationship'
 CREATE TABLE `relationship` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
   `relationship_definition_keyname` varchar(25) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
+  `created` datetime DEFAULT NULL,
+  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
+  `changed` datetime DEFAULT NULL,
+  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
+  `deleted` datetime DEFAULT NULL,
+  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
   `property_definition_keyname` varchar(50) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
   `related_property_definition_keyname` varchar(50) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
   `entity_definition_keyname` varchar(25) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,

  `entity_id` int(11) unsigned DEFAULT NULL,
  `related_entity_id` int(11) unsigned DEFAULT NULL,
  `master_relationship_id` int(11) unsigned DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `gae_key` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `gae_key` (`gae_key`),
  KEY `entity_id` (`entity_id`,`related_entity_id`),
  KEY `related_entity_id` (`related_entity_id`),
  KEY `master_relationship_id` (`master_relationship_id`),
  KEY `relationship_definition_keyname` (`relationship_definition_keyname`),
  KEY `property_definition_keyname` (`property_definition_keyname`),
  KEY `related_property_definition_keyname` (`related_property_definition_keyname`),
  KEY `entity_definition_keyname` (`entity_definition_keyname`),
  KEY `related_entity_definition_keyname` (`related_entity_definition_keyname`),
  CONSTRAINT `r_fk_rd`  FOREIGN KEY (`relationship_definition_keyname`)     REFERENCES `relationship_definition` (`keyname`),
  CONSTRAINT `r_fk_pd`  FOREIGN KEY (`property_definition_keyname`)         REFERENCES `property_definition` (`keyname`),
  CONSTRAINT `r_fk_rpd` FOREIGN KEY (`related_property_definition_keyname`) REFERENCES `property_definition` (`keyname`),
  CONSTRAINT `r_fk_e`   FOREIGN KEY (`entity_id`)                           REFERENCES `entity` (`id`),
  CONSTRAINT `r_fk_re`  FOREIGN KEY (`related_entity_id`)                   REFERENCES `entity` (`id`),
  CONSTRAINT `r_fk_ed`  FOREIGN KEY (`entity_definition_keyname`)           REFERENCES `entity_definition` (`keyname`),
  CONSTRAINT `r_fk_red` FOREIGN KEY (`related_entity_definition_keyname`)   REFERENCES `entity_definition` (`keyname`),
  CONSTRAINT `r_fk_mr`  FOREIGN KEY (`master_relationship_id`)              REFERENCES `relationship` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

CREATE TABLE `property` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `property_definition_keyname` varchar(50) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
  `entity_id` int(11) unsigned DEFAULT NULL,
  `ordinal` int(11) DEFAULT NULL,
  `language` varchar(10) COLLATE utf8_estonian_ci DEFAULT NULL,

-- Create syntax for TABLE 'app_settings'
CREATE TABLE `app_settings` (
  `keyname` varchar(25) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
  `value` varchar(500) COLLATE utf8_estonian_ci DEFAULT NULL,
  PRIMARY KEY (`keyname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'user'
CREATE TABLE `user` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `name` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `email` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `picture` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `language` varchar(10) COLLATE utf8_estonian_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'user_profile'
CREATE TABLE `user_profile` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `provider` varchar(20) COLLATE utf8_estonian_ci DEFAULT NULL,
  `provider_id` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `name` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `email` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `picture` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `session` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `provider` (`provider`,`provider_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `user_profile_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'file'
CREATE TABLE `file` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `filename` varchar(500) COLLATE utf8_estonian_ci DEFAULT NULL,
  `filesize` int(13) unsigned DEFAULT NULL,
  `file` longblob,
  `old_id` varchar(767) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `old_id` (`old_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'tmp_file'
CREATE TABLE `tmp_file` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `filename` varchar(500) COLLATE utf8_estonian_ci DEFAULT NULL,
  `filesize` int(13) unsigned DEFAULT NULL,
  `file` longblob,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'counter'
CREATE TABLE `counter` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `estonian_label` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `english_label` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `value` int(11) DEFAULT '1',
  `increment` int(11) NOT NULL DEFAULT '1',
  `type` enum('childcount','increment') COLLATE utf8_estonian_ci NOT NULL DEFAULT 'increment',
  `old_id` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `old_id` (`old_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

-- Create syntax for TABLE 'entity_definition'
CREATE TABLE `entity_definition` (
  `keyname` varchar(25) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
  `created` datetime DEFAULT NULL,
  `created_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `changed` datetime DEFAULT NULL,
  `changed_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `deleted` datetime DEFAULT NULL,
  `deleted_by` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ordinal` int(11) DEFAULT NULL,
  `public_path` varchar(100) COLLATE utf8_estonian_ci DEFAULT NULL,
  `estonian_label` varchar(500) COLLATE utf8_estonian_ci DEFAULT NULL,
