Exemplo n.º 1
0
 def create_table_if_not_exists(cls, connection):
     """timestamp can be null, if stream goes offline for example"""
     Trait.create_table_if_not_exists(connection)
     Special.create_table_if_not_exists(connection)
     connection.execute(
         """create table if not exists characters
         (character_id integer PRIMARY KEY   NOT NULL,
         name            text    UNIQUE    NOT NULL,
         user_id         text    UNIQUE    NOT NULL,
         experience      integer NOT NULL,
         lvl             integer NOT NULL,
         weapon_id       integer,
         armor_id        integer,
         trait_id        text    NOT NULL,
         exp_gain_time   timestamp,
         x               integer NOT NULL,
         y               integer NOT NULL,
         trait_bonus     real,
         alive           boolean NOT NULL DEFAULT 1,
           FOREIGN KEY (weapon_id)   REFERENCES weapons(weapon_id),
           FOREIGN KEY (armor_id)    REFERENCES armors(armor_id),
           FOREIGN KEY (trait_id)    REFERENCES traits(orig_name)
         );"""
     )
     if "alive" not in [i[1] for i in connection.execute("""PRAGMA table_info(characters)""")]:
         connection.execute("""ALTER TABLE characters ADD COLUMN alive boolean NOT NULL DEFAULT 1;""")
     SpecialCooldown.create_table_if_not_exists(connection)
     ActiveEffect.create_table_if_not_exists(connection)
Exemplo n.º 2
0
 def create_table_if_not_exists(cls, connection):
     """timestamp can be null, if stream goes offline for example"""
     Trait.create_table_if_not_exists(connection)
     Special.create_table_if_not_exists(connection)
     connection.execute("""create table if not exists characters
         (character_id integer PRIMARY KEY   NOT NULL,
         name            text    UNIQUE    NOT NULL,
         user_id         text    UNIQUE    NOT NULL,
         experience      integer NOT NULL,
         lvl             integer NOT NULL,
         weapon_id       integer,
         armor_id        integer,
         trait_id        text    NOT NULL,
         exp_gain_time   timestamp,
         x               integer NOT NULL,
         y               integer NOT NULL,
         trait_bonus     integer,
           FOREIGN KEY (weapon_id)   REFERENCES weapons(weapon_id),
           FOREIGN KEY (armor_id)    REFERENCES armors(armor_id),
           FOREIGN KEY (trait_id)    REFERENCES traits(orig_name)
         );""")
     SpecialCooldown.create_table_if_not_exists(connection)
     ActiveEffect.create_table_if_not_exists(connection)