{"id":29089373,"url":"https://github.com/gigagrug/schema","last_synced_at":"2026-01-21T13:25:21.437Z","repository":{"id":296098527,"uuid":"961653699","full_name":"gigagrug/schema","owner":"gigagrug","description":"All in one CLI tool for the database | Migration, Studio, LSP","archived":false,"fork":false,"pushed_at":"2025-12-25T00:18:17.000Z","size":20543,"stargazers_count":212,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-01-19T22:55:35.886Z","etag":null,"topics":["bubbletea","cli","database-migrations","database-schema","lsp","lsp-server","mariadb","mysql","postgres","sql","sqlite","studio","tui","turso"],"latest_commit_sha":null,"homepage":"https://schema.gigagrug.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gigagrug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"gigagrug","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-04-07T00:12:55.000Z","updated_at":"2026-01-19T14:27:44.000Z","dependencies_parsed_at":"2025-05-29T00:34:30.618Z","dependency_job_id":"4937beff-a9ac-4da2-9c70-9c99851528a2","html_url":"https://github.com/gigagrug/schema","commit_stats":null,"previous_names":["gigagrug/schema"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/gigagrug/schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigagrug%2Fschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigagrug%2Fschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigagrug%2Fschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigagrug%2Fschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gigagrug","download_url":"https://codeload.github.com/gigagrug/schema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigagrug%2Fschema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bubbletea","cli","database-migrations","database-schema","lsp","lsp-server","mariadb","mysql","postgres","sql","sqlite","studio","tui","turso"],"created_at":"2025-06-28T04:01:43.466Z","updated_at":"2026-01-21T13:25:21.415Z","avatar_url":"https://github.com/gigagrug.png","language":"Go","readme":"# Schema\nAll in one CLI tool for the database | SQLite, libSQL, Turso, PostgreSQL, MySQL, MariaDB\n\n![schema](./docs/assets/schema.png)\n\n## Installation\nInstall/upgrade latest version\n```shell\ncurl -sSfL https://raw.githubusercontent.com/gigagrug/schema/main/install.sh | sh -s\n```\nInstall specific version \n```shell\ncurl -sSfL https://raw.githubusercontent.com/gigagrug/schema/main/install.sh | sh -s 0.1.0\n```\n\n## Get Started\n### Step 1\nInit project (default: db=sqlite url=./schema/dev.db) \n```shell\nschema i\n```\nInit project using another db and url\n```shell\nschema i -db \"postgres\" -url \"postgresql://postgres:postgres@localhost:5432/postgres\"\n```\nInit project with different root directory\n```shell\nschema i -rdir \"schema2\"\n```\n### Step 2\nNessesary if using existing database\n```shell\nschema pull\n```\n\n## Migrations\n### Step 1\nCreate a SQL file\n```shell\nschema create \"initschema\"\n```\n### Step 2\nGo to ./schema/migrations/1_initschema.sql (This SQL is for sqlite)\n```sql\nCREATE TABLE IF NOT EXISTS users (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    username TEXT NOT NULL UNIQUE,\n    email TEXT NOT NULL UNIQUE,\n    password TEXT NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS posts (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,\n    title TEXT NOT NULL,\n    content TEXT NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\n-- schema rollback\nDROP TABLE users;\nDROP TABLE posts;\n```\n### Step 3\nMigrates all the sql files not migrated \n```shell\nschema migrate\n```\nMigrates specific sql file\n```shell\nschema migrate \"1_initschema\"\n```\n\n## Rollback\nRollbacks last migrated file\n```shell\nschema rollback\n```\n```shell\nschema rollback \"1_initschema\"\n```\n\n## Remove\nRemoves if file not migrated\n```shell\nschema remove \"1_initschema\"\n```\n\n## Insert Dummy Data\n### Step 1\nDoesn't save in _schema_migrations table if not in migrations dir so they can be reused\n```shell\nschema create \"insertdata\" -dir \"inserts\"\n```\n### Step 2\nInsert based on the SQL schema above. \n```sql\nWITH RECURSIVE generate_users AS (\n  SELECT ABS(RANDOM() % 10000) AS random_number, 1 AS row_number\n  UNION ALL\n  SELECT ABS(RANDOM() % 10000), row_number + 1\n  FROM generate_users\n  WHERE row_number \u003c 5\n)\nINSERT INTO users (username, email, password)\nSELECT \n  'user_' || random_number, \n  'user_' || random_number || '@example.com', \n  'password'\nFROM generate_users;\n\nWITH RECURSIVE user_list AS (\n  SELECT id, ROW_NUMBER() OVER () AS rn\n  FROM users\n  ORDER BY RANDOM()\n  LIMIT 5\n),\npost_insert AS (\n  SELECT\n    'Post #' || ABS(RANDOM() % 10000) AS title,\n    'This is a post about random topic #' || ABS(RANDOM() % 10000) AS content,\n    id AS user_id\n  FROM user_list\n)\nINSERT INTO posts (user_id, title, content)\nSELECT user_id, title, content FROM post_insert;\n```\n### Step 3\n```shell\nschema sql \"0_insertdata.sql\" -dir \"inserts\"\n```\n\n## Select query and prints table in console\n```shell\nschema sql \"SELECT * FROM users;\"\n```\n![table](./docs/assets/table.png)\n\n## TUI SQL Studio\n```shell\nschema studio\n```\n![studio](./docs/assets/studio.gif)\n\n## LSP\n```shell\nschema lsp\n```\n![lsp](./docs/assets/lsp.gif)\n\n## Headless\nIf you don't want to use .env and schema.db\nExample:\n```shell\nschema studio -db \"sqlite\" -url \"./schema/dev.db\"\n```\n\n## Subcommands\n`version`, `v`: Shows current and latest version \u003cbr\u003e\n`init`, `i`: Initializes project\u003cbr\u003e\n`pull`: Pulls database schema \u003cbr\u003e\n`migrate`: Migrates pending migrations \u003cbr\u003e\n`rollback`: Rollbacks last migration \u003cbr\u003e\n`studio`: Launch SQL TUI Studio\u003cbr\u003e\n`lsp`: Connect to your editor \u003cbr\u003e\n`rollback \"[filename]\"` Rollback a specific migration \u003cbr\u003e\n`migrate \"[filename under migrations/]\"` Run a specific migration \u003cbr\u003e\n`sql \"[filename or sql query]\"` Run SQL directly or from a file \u003cbr\u003e\n`create \"[filename]\"`: Create a new migration file \u003cbr\u003e\n`remove \"[filename]\"`, `rm`: Remove an unmigrated file from disk and db \u003cbr\u003e\n`config`: Edit config files for db type and db url\u003cbr\u003e\n\n## Flags\n`db=\"[db type]\"` (default sqlite) \u003cbr\u003e\n`url=\"[db url]\"` (default ./schema/dev.db) \u003cbr\u003e\n`dir=\"[dir under rdir]\"` (default migration) \u003cbr\u003e\n`rdir=\"[root directory]\"` (default schema)\n","funding_links":["https://github.com/sponsors/gigagrug"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigagrug%2Fschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgigagrug%2Fschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigagrug%2Fschema/lists"}