|
| 1 | +-- remove tables not to be used |
| 2 | +DROP TABLE IF EXISTS map.map_system_note; |
| 3 | +DROP TABLE IF EXISTS map.map_system_structure; |
| 4 | + |
| 5 | +-- intel_system_structure |
| 6 | +CREATE TABLE map.intel_system_structure |
| 7 | +( |
| 8 | + id INTEGER PRIMARY KEY, |
| 9 | + map_id INTEGER NOT NULL REFERENCES map (id), |
| 10 | + system_id INTEGER NOT NULL, |
| 11 | + name TEXT, |
| 12 | + owner_corporation_id INTEGER REFERENCES corporation (id), |
| 13 | + item_type_id INTEGER NOT NULL, |
| 14 | + nearest_planet_idx INTEGER, |
| 15 | + nearest_moon_idx INTEGER, |
| 16 | + is_online INTEGER, |
| 17 | + is_deleted INTEGER NOT NULL DEFAULT 0, |
| 18 | + |
| 19 | + created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000), |
| 20 | + updated_at INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT (unixepoch() * 1000), |
| 21 | + deleted_at INTEGER, |
| 22 | + |
| 23 | + created_by_character_id INTEGER NOT NULL, |
| 24 | + updated_by_character_id INTEGER NOT NULL, |
| 25 | + deleted_by_character_id INTEGER, |
| 26 | + |
| 27 | + CHECK (name is null or length(name) > 0), |
| 28 | + CHECK (is_online is null or is_online is 0 or is_online is 1), |
| 29 | + CHECK (is_deleted is 0 or (is_deleted is 1 and deleted_at is not null and deleted_by_character_id is not null)) |
| 30 | +) STRICT; |
| 31 | + |
| 32 | +-- intel_system |
| 33 | +CREATE TABLE map.intel_system |
| 34 | +( |
| 35 | + map_id INTEGER NOT NULL REFERENCES map (id), |
| 36 | + system_id INTEGER NOT NULL, |
| 37 | + |
| 38 | + primary_corporation_id INTEGER REFERENCES corporation (id), |
| 39 | + primary_alliance_id INTEGER REFERENCES alliance (id), |
| 40 | + |
| 41 | + intel_group INTEGER NOT NULL DEFAULT 0, |
| 42 | + is_empty INTEGER NOT NULL DEFAULT 0, |
| 43 | + |
| 44 | + created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000), |
| 45 | + updated_at INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT (unixepoch() * 1000), |
| 46 | + created_by_character_id INTEGER NOT NULL, |
| 47 | + updated_by_character_id INTEGER NOT NULL, |
| 48 | + |
| 49 | + UNIQUE (map_id, system_id), |
| 50 | + |
| 51 | + CHECK (intel_group < 0 and intel_group < 4), |
| 52 | + CHECK (is_empty is 0 or is_empty is 1) |
| 53 | +) STRICT; |
| 54 | + |
| 55 | +-- intel_system_note |
| 56 | +CREATE TABLE map.intel_system_note |
| 57 | +( |
| 58 | + id INTEGER PRIMARY KEY, |
| 59 | + map_id INTEGER NOT NULL REFERENCES map (id), |
| 60 | + system_id INTEGER NOT NULL, |
| 61 | + note TEXT NOT NULL, |
| 62 | + |
| 63 | + is_pinned INTEGER NOT NULL DEFAULT 0, |
| 64 | + is_deleted INTEGER NOT NULL DEFAULT 0, |
| 65 | + original_id INTEGER REFERENCES intel_system_note (id), |
| 66 | + |
| 67 | + created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000), |
| 68 | + created_by_character_id INTEGER NOT NULL, |
| 69 | + |
| 70 | + deleted_at INTEGER, |
| 71 | + deleted_by_character_id INTEGER, |
| 72 | + |
| 73 | + CHECK (length(note) > 0), |
| 74 | + CHECK (is_deleted is 0 or (is_deleted is 1 and deleted_at is not null and deleted_by_character_id is not null)) |
| 75 | +) STRICT; |
| 76 | + |
| 77 | +-- intel_system_ping |
| 78 | +CREATE TABLE map.intel_system_ping |
| 79 | +( |
| 80 | + id INTEGER PRIMARY KEY, |
| 81 | + map_id INTEGER NOT NULL REFERENCES map (id), |
| 82 | + system_id INTEGER NOT NULL, |
| 83 | + |
| 84 | + ping_user_id INTEGER, |
| 85 | + ping_map_global INTEGER, |
| 86 | + ping_note TEXT, |
| 87 | + is_deleted INTEGER NOT NULL DEFAULT 0, |
| 88 | + |
| 89 | + created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000), |
| 90 | + created_by_character_id INTEGER NOT NULL, |
| 91 | + |
| 92 | + deleted_at INTEGER, |
| 93 | + deleted_by_character_id INTEGER, |
| 94 | + |
| 95 | + CHECK (is_deleted is 0 or (is_deleted is 1 and deleted_at is not null and deleted_by_character_id is not null)), |
| 96 | + CHECK (ping_user_id is not null or ping_map_global is not null), |
| 97 | + CHECK (ping_map_global is null or ping_map_global is 1) |
| 98 | +) STRICT; |
| 99 | + |
| 100 | +-- intel_group_stance |
| 101 | +CREATE TABLE map.intel_group_stance |
| 102 | +( |
| 103 | + map_id INTEGER NOT NULL REFERENCES map (id), |
| 104 | + |
| 105 | + corporation_id INTEGER REFERENCES corporation (id), |
| 106 | + alliance_id INTEGER REFERENCES alliance (id), |
| 107 | + stance INTEGER NOT NULL, |
| 108 | + |
| 109 | + created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000), |
| 110 | + created_by_character_id INTEGER NOT NULL, |
| 111 | + |
| 112 | + updated_at INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT (unixepoch() * 1000), |
| 113 | + updated_by_character_id INTEGER NOT NULL, |
| 114 | + |
| 115 | + UNIQUE (map_id, corporation_id, alliance_id), |
| 116 | + CHECK (corporation_id is not null or alliance_id is not null), |
| 117 | + CHECK (stance >= 0 or stance < 3) |
| 118 | +) STRICT; |
| 119 | + |
| 120 | +-- intel_character |
| 121 | +CREATE TABLE map.intel_character |
| 122 | +( |
| 123 | + id INTEGER PRIMARY KEY, |
| 124 | + bloodline_id INTEGER NOT NULL, |
| 125 | + corporation_id INTEGER NOT NULL, |
| 126 | + faction_id INTEGER, |
| 127 | + gender TEXT NOT NULL, |
| 128 | + name TEXT NOT NULL, |
| 129 | + race_id INTEGER NOT NULL, |
| 130 | + security_status REAL, |
| 131 | + title TEXT, |
| 132 | + |
| 133 | + created_at INTEGER NOT NULL, |
| 134 | + updated_at INTEGER NOT NULL, |
| 135 | + |
| 136 | + UNIQUE (name) |
| 137 | +) STRICT; |
0 commit comments