{"id":21707829,"url":"https://github.com/flightaware/fa_schema_tools","last_synced_at":"2025-03-20T17:22:30.141Z","repository":{"id":590376,"uuid":"224704","full_name":"flightaware/fa_schema_tools","owner":"flightaware","description":"Schema tools for PostgreSQL including comparing two database schema for differences, making sure all tables have a primary or unique key, and more...","archived":false,"fork":false,"pushed_at":"2018-02-21T00:51:49.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-04-18T10:34:08.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Tcl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flightaware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-06-11T18:48:21.000Z","updated_at":"2023-04-18T10:34:08.719Z","dependencies_parsed_at":"2022-07-07T18:02:17.137Z","dependency_job_id":null,"html_url":"https://github.com/flightaware/fa_schema_tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flightaware%2Ffa_schema_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flightaware%2Ffa_schema_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flightaware%2Ffa_schema_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flightaware%2Ffa_schema_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flightaware","download_url":"https://codeload.github.com/flightaware/fa_schema_tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244657147,"owners_count":20488727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T22:19:24.681Z","updated_at":"2025-03-20T17:22:30.114Z","avatar_url":"https://github.com/flightaware.png","language":"Tcl","funding_links":[],"categories":[],"sub_categories":[],"readme":"FlightAware Schema Tools\n---\n\n*FlightAware Schema Tools* consists of a package and programs to pull schema definitions out of PostgreSQL and interpret them in various ways.\n\nThe most important is probably the ability to obtain and then compare the definition of two Postgres database schemas, reporting every table that is in one but not the other and reporting the differences in the definition of each table, for any tables where differences exist, and producing ALTER TABLE, CREATE INDEX, and DROP INDEX commands to make the second database schema match the first.\n\nfa_schema_tools requires Tcl 8.5 or newer be installed and requires that the TclX extension and the tcllauncher extension be installed as well (https://github.com/flightaware/tcllauncher)\n\nfa_pg_schema_to_tcl\n---\n\n**fa_pg_schema_to_tcl** connects to a PostgreSQL database, reads the database definition from various tables, and produces Tcl code that can be executed to render that database's schema definition into Tcl data structures for further interpretation, groping, etc.\n\nExample usage:\n```sh\n fa_pg_schema_to_tcl dbname DATABASENAME host HOST1 user USER password PASSWORD \u003e/tmp/schema1\n\n fa_pg_schema_to_tcl dbname DATABASENAME host HOST2 user USER password PASSWORD \u003e/tmp/schema2\n```\n\nfa_pg_schema_compare\n---\n\n**fa_pg_schema_compare** compares the definition of two database schemas produced by **fa_pg_schema_to_tcl**, reporting every table that is in one but not the other and reporting the differences in the definition of each table, if differences exist, and producing *ALTER TABLE* commands to make the second database schema match the first.\n\n\n```sh\n fa_pg_schema_compare /tmp/schema1 /tmp/schema2\n```\n\n```\n -- tables defined in second schema only:\n --     accounts_myspace\n\n -- Added package_delivery index \"package_delivery_date\"\n CREATE INDEX package_delivery_date ON package_delivery USING btree (date);\n\n -- Added package_geo fields \"continent sub_continent\"\n ALTER TABLE package_geo ADD COLUMN continent character varying;\n ALTER TABLE package_geo ADD COLUMN sub_continent character varying;\n```\n\nfa_pg_keycheck\n---\n\n**fa_pg_keycheck** is a Tcl program that qualify a PostgreSQL database for use with replication via the **Slony** replication system (http://slony.info/).  fa_pg_keycheck gropes through a database, looking at the metadata information for each the tables to see if there's a primary key for the table and, if not, to see if there's a unique key that's comprised of one or more fields, all of which are non-null.\n\nAll tables matching one of those criteria can be fed straight to slony.\n\nTables that don't have a primary key or non-null unique key need to have one added before they can be used with Slony.  For any tables it finds that do not fit the criteria, fa_pg_keycheck will emit the DDL necessary to create a unique key and index. For instance for a table named *monkey* that has no qualifying index, it will emit\n\n```sql\n-- monkey create new column 'id'\nbegin;\n  create sequence monkey_id_seq;\n  alter table monkey add column id integer;\n  update monkey set id = nextval('monkey_id_seq');\n  alter table monkey alter column id set not null;\n  create unique index monkey_id_key on monkey (id);\nend;\n```\n\nFinally, fa_pg_keycheck will emit configuration data for all the database tables that can be pasted into slony, including tables that have a primary key, tables that do not have a primary key but have a unique key along with the qualifying key name, and a list of all the sequences to be replicated.\n\nCarefully inspect the output before running anything.  We recommend using a test database before trying it on your production one.  You'll also probably need to issue some GRANTs on the new keys and sequences to appropriate users and/or roles.\n\n\nfa_pg_log_groper\n---\n\nfa_pg_log_groper will follow a syslog file that PostgreSQL is logging to and reaseemble the multi-line logging format into single lines.  Handy for seeing what's going on because log messages will often span many log lines.\n\n\nHow To Dump Just The Schema\n---\n\nAs user pgsql or something,\n\npg_dumpall --schema-only asdidata \u003easdidata.sql\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflightaware%2Ffa_schema_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflightaware%2Ffa_schema_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflightaware%2Ffa_schema_tools/lists"}