-- Convert schema './FileFormats-Schema-0.03-SQLite.sql' to './FileFormats-Schema-0.04-SQLite.sql':

BEGIN;

CREATE TABLE enum_values (
  enum_id integer NOT NULL,
  value varchar(1024) NOT NULL,
  translation varchar(1024) NOT NULL,
  PRIMARY KEY (enum_id, value)
);

CREATE INDEX enum_values_idx_enum_id_enum_v_enum_value ON enum_values (enum_id);


CREATE INDEX encoded_string_idx_base_type_id_encoded_stri_ ON encoded_string (base_type_id);
CREATE INDEX enum_idx_base_type_id_enum_enu ON enum (base_type_id);

CREATE INDEX fileformats_idx_base_type_id_f_fileformat ON fileformats (base_type_id);
CREATE INDEX recurring_count_idx_base_type_id_recurring_co_ ON recurring_count (base_type_id);
CREATE INDEX recurring_terminated_idx_base_type_id_recurring_te_ ON recurring_terminated (base_type_id);

CREATE TEMPORARY TABLE structure_fields_temp_alter (
  struct_id integer NOT NULL,
  field_id integer NOT NULL,
  name varchar(255) NOT NULL,
  position integer NOT NULL,
  type_id integer NOT NULL,
  value varchar(1024) NOT NULL,
  comments varchar(1024) NOT NULL,
  PRIMARY KEY (struct_id, field_id)
);
-- INSERT INTO structure_fields_temp_alter SELECT struct_id, field_id, name, position, type_id, value, comments FROM structure_fields;
DROP TABLE structure_fields;
CREATE TABLE structure_fields (
  struct_id integer NOT NULL,
  field_id integer NOT NULL,
  name varchar(255) NOT NULL,
  position integer NOT NULL,
  type_id integer NOT NULL,
  value varchar(1024) NOT NULL,
  comments varchar(1024) NOT NULL,
  PRIMARY KEY (struct_id, field_id)
);
CREATE INDEX structure_fields_idx_struct_id_structure_field_ ON structure_fields (struct_id);
CREATE INDEX structure_fields_idx_type_id_s_structure_field ON structure_fields (type_id);
-- INSERT INTO structure_fields SELECT struct_id, field_id, name, position, type_id, value, comments FROM structure_fields_temp_alter;
DROP TABLE structure_fields_temp_alter;


CREATE TEMPORARY TABLE types_temp_alter (
  id INTEGER PRIMARY KEY NOT NULL,
  system_id integer NOT NULL,
  name varchar(255) NOT NULL,
  comments varchar(16384)
);
INSERT INTO types_temp_alter SELECT id, system_id, name, comments FROM types;
DROP TABLE types;
CREATE TABLE types (
  id INTEGER PRIMARY KEY NOT NULL,
  system_id integer NOT NULL,
  name varchar(255) NOT NULL,
  comments varchar(16384)
);
CREATE INDEX types_idx_system_id_types_t00 ON types (system_id);
INSERT INTO types SELECT id, system_id, name, comments FROM types_temp_alter;
DROP TABLE types_temp_alter;


COMMIT;

