Skip to content

Instantly share code, notes, and snippets.

@paulfitz
Created May 19, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulfitz/7ec641c26a9eced0d7c10234058f4004 to your computer and use it in GitHub Desktop.
Save paulfitz/7ec641c26a9eced0d7c10234058f4004 to your computer and use it in GitHub Desktop.
current find.coop schema
CREATE TABLE tag_contexts (
id INTEGER NOT NULL,
name TEXT,
friendly_name TEXT,
PRIMARY KEY (id)
);
CREATE TABLE tags (
id INTEGER NOT NULL,
name TEXT,
root_id INTEGER,
root_type TEXT, parent_id INTEGER, effective_id INTEGER, created_at DATETIME, updated_at DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE tag_worlds (
id INTEGER NOT NULL,
name TEXT,
PRIMARY KEY (id)
);
CREATE TABLE users (
id INTEGER NOT NULL,
login TEXT, password TEXT, is_admin INTEGER, person_id INTEGER, last_login DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE organizations (
id INTEGER NOT NULL,
grouping TEXT, dccid TEXT, created_at DATETIME, updated_at DATETIME, fax TEXT, year_founded DATETIME, dso TEXT, dso_update TEXT, name TEXT, description TEXT, phone TEXT, email TEXT, website TEXT, democratic TEXT, import_notice_sent_at TEXT, email_response_token TEXT, responded_at TEXT, response TEXT, access_rule_id INTEGER, primary_location_id INTEGER, oid TEXT, "group" TEXT,
PRIMARY KEY (id)
);
CREATE TABLE locations (
id INTEGER NOT NULL,
mailing_address1 TEXT, mailing_address2 TEXT, mailing_city TEXT, mailing_state TEXT, mailing_zip TEXT, mailing_country TEXT, mailing_county TEXT, physical_county TEXT, dccid TEXT, created_at DATETIME, updated_at DATETIME, note TEXT, dso TEXT, dso_update TEXT, taggable_id INTEGER, physical_address1 TEXT, physical_address2 TEXT, physical_city TEXT, physical_state TEXT, physical_zip TEXT, physical_country TEXT, latitude FLOAT, longitude FLOAT, taggable_type TEXT,
PRIMARY KEY (id)
);
CREATE TABLE people (
id INTEGER NOT NULL,
firstname TEXT, lastname TEXT, updated_at DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE organizations_people (
id INTEGER NOT NULL,
person_id INTEGER, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE product_services (
id INTEGER NOT NULL,
name TEXT, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE organizations_users (
id INTEGER NOT NULL,
user_id INTEGER, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE access_rules (
id INTEGER NOT NULL,
access_type TEXT,
PRIMARY KEY (id)
);
CREATE TABLE data_sharing_orgs (
id INTEGER NOT NULL,
name TEXT, dso TEXT, dso_update TEXT, created_at DATETIME, updated_at DATETIME, default_import_plugin_name TEXT, dccid TEXT, key TEXT,
PRIMARY KEY (id)
);
CREATE TABLE data_sharing_orgs_users (
id INTEGER NOT NULL,
user_id INTEGER, data_sharing_org_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE member_orgs_organizations (
id INTEGER NOT NULL,
member_org_id INTEGER, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE org_types_organizations (
id INTEGER NOT NULL,
org_type_id INTEGER, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE organizations_sectors (
id INTEGER NOT NULL,
sector_id INTEGER, organization_id INTEGER,
PRIMARY KEY (id)
);
CREATE TABLE member_orgs (
id INTEGER NOT NULL,
name TEXT, created_at DATETIME, updated_at DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE sectors (
id INTEGER NOT NULL,
name TEXT, created_at TEXT, updated_at TEXT,
PRIMARY KEY (id)
);
CREATE TABLE taggings (
id INTEGER NOT NULL,
tag_id INTEGER, taggable_id INTEGER, taggable_type TEXT, dso TEXT, dso_update TEXT, created_at DATETIME, dccid TEXT,
PRIMARY KEY (id)
);
CREATE TABLE data_sharing_orgs_taggables (
id INTEGER NOT NULL,
data_sharing_org_id INTEGER, taggable_id INTEGER, taggable_type TEXT, verified INTEGER, dso TEXT, dso_update TEXT, created_at DATETIME, updated_at DATETIME, foreign_key_id TEXT, dccid TEXT,
PRIMARY KEY (id)
);
CREATE TABLE org_types (
id INTEGER NOT NULL,
name TEXT,
description TEXT,
created_at DATETIME,
updated_at DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE legal_structures (
id INTEGER NOT NULL,
name TEXT,
created_at DATETIME,
updated_at DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE oids (
id INTEGER NOT NULL,
dccid TEXT,
oid TEXT,
PRIMARY KEY (id)
);
CREATE INDEX ix_tag_contexts_6ae999552a0d2dca ON tag_contexts (name);
CREATE INDEX ix_tags_6ae999552a0d2dca ON tags (name);
CREATE INDEX ix_tag_worlds_6ae999552a0d2dca ON tag_worlds (name);
CREATE INDEX ix_access_rules_87ea5dfc8b8e384d ON access_rules (id);
CREATE INDEX ix_data_sharing_orgs_6ae999552a0d2dca ON data_sharing_orgs (name);
CREATE INDEX ix_data_sharing_orgs_1d6d94da1e93927d ON data_sharing_orgs (dccid);
CREATE INDEX ix_org_types_6ae999552a0d2dca ON org_types (name);
CREATE INDEX ix_sectors_6ae999552a0d2dca ON sectors (name);
CREATE INDEX ix_legal_structures_6ae999552a0d2dca ON legal_structures (name);
CREATE INDEX ix_member_orgs_6ae999552a0d2dca ON member_orgs (name);
CREATE INDEX ix_organizations_1d6d94da1e93927d ON organizations (dccid);
CREATE INDEX ix_locations_1d6d94da1e93927d ON locations (dccid);
CREATE INDEX ix_taggings_1d6d94da1e93927d ON taggings (dccid);
CREATE INDEX ix_data_sharing_orgs_taggables_1d6d94da1e93927d ON data_sharing_orgs_taggables (dccid);
CREATE INDEX ix_oids_1d6d94da1e93927d ON oids (dccid);
CREATE INDEX ix_organizations_2118c8699c550662 ON organizations (oid);
CREATE INDEX ix_data_sharing_orgs_taggables_90868c357657838e ON data_sharing_orgs_taggables (data_sharing_org_id, taggable_id, taggable_type);
CREATE INDEX ix_taggings_94bc7f962f82a803 ON taggings (tag_id, taggable_id, taggable_type);
CREATE INDEX ix_product_services_472c1f99a32def1b ON product_services (organization_id);
CREATE INDEX ix_organizations_sectors_472c1f99a32def1b ON organizations_sectors (organization_id);
CREATE INDEX ix_organizations_sectors_668b2ea8a2f53442 ON organizations_sectors (sector_id);
CREATE INDEX ix_organizations_people_472c1f99a32def1b ON organizations_people (organization_id);
CREATE INDEX ix_organizations_people_5fdaf670315c4b7e ON organizations_people (person_id);
CREATE INDEX ix_tags_c51485bf1a773cf3 ON tags (root_id, root_type);
CREATE INDEX ix_tags_bf93c41ee1ae1649 ON tags (parent_id);
CREATE INDEX ix_taggings_8e4052373c579afc ON taggings (tag_id);
CREATE INDEX ix_taggings_0a6e8b1431918283 ON taggings (taggable_id, taggable_type);
CREATE INDEX ix_locations_0a6e8b1431918283 ON locations (taggable_id, taggable_type);
CREATE INDEX ix_data_sharing_orgs_taggables_e83626ab466411b8 ON data_sharing_orgs_taggables (data_sharing_org_id);
CREATE INDEX ix_data_sharing_orgs_taggables_b16ab217725cad65 ON data_sharing_orgs_taggables (taggable_type);
CREATE INDEX ix_data_sharing_orgs_taggables_0a6e8b1431918283 ON data_sharing_orgs_taggables (taggable_id, taggable_type);
CREATE INDEX data_sharing_orgs_key on data_sharing_orgs(key);
CREATE TABLE sources (name,'key',name_of_organization,description,source_directory_link,source_info_link);
CREATE INDEX sources_key on sources(key);
CREATE INDEX sources_name on sources(name);
CREATE TABLE units_taggables(
id INTEGER NOT NULL,
taggable_id INTEGER NOT NULL,
taggable_type TEXT NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX idx_units_taggables_out ON units_taggables(taggable_id, taggable_type);
CREATE VIRTUAL TABLE units USING fts4(taggable_id, taggable_type,
name,
description,
phone,
email,
website,
notindexed=taggable_id, notindexed=taggable_type)
/* units(taggable_id,taggable_type,name,description,phone,email,website) */;
CREATE TABLE IF NOT EXISTS 'units_content'(docid INTEGER PRIMARY KEY, 'c0taggable_id', 'c1taggable_type', 'c2name', 'c3description', 'c4phone', 'c5email', 'c6website');
CREATE TABLE IF NOT EXISTS 'units_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
CREATE TABLE IF NOT EXISTS 'units_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
CREATE TABLE IF NOT EXISTS 'units_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
CREATE TABLE IF NOT EXISTS 'units_stat'(id INTEGER PRIMARY KEY, value BLOB);
@paulfitz
Copy link
Author

In case it helps, a graphical version of above. Unfortunately for rails apps, relationships are managed by rails not by db, so there's no foreign key info to give a good rendering of the schema with the tool I used (schemacrawler)

graphical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment