{"id":20671091,"url":"https://github.com/allnulled/mysql-schema","last_synced_at":"2025-03-10T17:22:10.845Z","repository":{"id":57142342,"uuid":"249184192","full_name":"allnulled/mysql-schema","owner":"allnulled","description":"Generate a JSON representing the schema of your MySQL database.","archived":false,"fork":false,"pushed_at":"2021-03-10T15:40:24.000Z","size":188,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T00:48:04.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mysql-schema","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allnulled.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-22T13:01:03.000Z","updated_at":"2022-02-17T16:49:39.000Z","dependencies_parsed_at":"2022-09-05T08:51:15.139Z","dependency_job_id":null,"html_url":"https://github.com/allnulled/mysql-schema","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fmysql-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fmysql-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fmysql-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fmysql-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/mysql-schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242889572,"owners_count":20201987,"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-16T20:24:58.037Z","updated_at":"2025-03-10T17:22:10.824Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","readme":"# mysql-schema\n\nGenerate a JSON representing the schema of your MySQL database.\n\n## Install\n\n`$ npm i -g mysql-schema`\n\n## Why?\n\nTo generate schema definitions of MySQL databases automatically.\n\nTo abstract your code and repeat things the least possible.\n\nWhen you care about the shape, content relies on you. *Be water.*\n\n## Usage\n\nThis tool enables you to generate a `json` file representing your `mysql` database.\n\n### CLI usage\n\nThis is a short explanation of how the CLI works.\n\n```bash\n$ mysql-schema\n\t[--user]           root               # database user                 = process.env.DB_USER           || 'root'\n\t[--password]                          # database user password        = process.env.DB_PASSWORD       || ''\n\t[--host]           127.0.0.1          # database host                 = process.env.DB_HOST           || '127.0.0.1'\n\t[--port]           3306               # database port                 = process.env.DB_PORT           || 3306\n\t[--database]       test               # database name                 = process.env.DB_NAME           || 'test'\n\t[--configurations]                    # database configurations file  = process.env.DB_CONFIGURATIONS || false\n\t[--extensions]                        # database schema extensions    = process.env.DB_EXTENSIONS     || false\n\t[--as-json]                           # to generate a json \u0026 not a js = false\n\t--output           schema.{db}.js     # output file                   = \"schema.${database}.js\"\n```\n\n### API usage\n\nThis is a short explanation of how the API works.\n\n```js\nrequire(\"mysql-schema\").getSchema({\n\tuser:            process.env.DB_USER           || 'root',\n\tpassword:        process.env.DB_PASSWORD       || '',\n\thost:            process.env.DB_HOST           || '127.0.0.1',\n\tport:            process.env.DB_PORT           || '3306',\n\tdatabase:        process.env.DB_NAME           || 'test',\n\tconfigurations:  process.env.DB_CONFIGURATIONS || false,\n\textensions:      process.env.DB_EXTENSIONS     || false,\n\tasJson:          false,\n\toutput:          `./schema.${database}.js`\n})\n```\n\n## API reference\n\n\n\n\n### `const MySQLSchema = require(\"mysql-schema\")`\n\nMaster class of the `mysql-schema` API.\n\n\n\n\n### `MySQLSchema.getSchema(options:Object):Promise\u003cschema:Object\u003e`\n\n\n\n**Asynchronous**.\n\n\n**Description**:  Generates a schema representing the MySQL database pointing.\n\n\n**Parameter**:  `options` - object with properties (all of them optional):\n\n   - `user`:           `string` - user of the database\n       - *default:*      **`process.env.DB_USER`** or `\"root\"`\n   - `password`:       `string` - password of the database\n       - *default:*      **`process.env.DB_PASSWORD`** or `\"\"`\n   - `host`:           `string` - host of the database\n       - *default:*      **`process.env.DB_HOST`** or `\"127.0.0.1\"`\n   - `port`:           `string` - port of the database\n       - *default:*      **`process.env.DB_PORT`** or `3306`\n   - `database`:       `string` - name of the database\n       - *default:*      **`process.env.DB_NAME`** or `\"test\"`\n   - `configurations`: `string` - configurations file for the database (overrides the other parameters)\n       - *default:*      **`process.env.DB_CONFIGURATIONS`** or `false`\n       - *usage:*        object that allows to set the same database configuration from an external file.\n   - `extensions`:     `string` - extensions file for the generation\n       - *default:*      **`process.env.DB_EXTENSIONS`** or `false`\n       - *usage:* object that allows to extend the schema:\n           - `perTable`:      filled with nested table, column, and extension properties.\n           - `perColumn`:     filled with nested column, and extension properties.\n           - in `general`:    filled with extension properties.\n   - `asJson`:         `boolean` - flag to output a `json` instead of a `js` file\n       - *default:*      `false`\n       - *usage:*        flag to output a JSON file. As JSON, functions, regex and dates are lost as genuine types in the exportation.\n   - `output`:         `string` - destination of the file with the schema\n       - *default:*      **`process.env.DB_SCHEMA`** or `false`\n\n\n\n\n### `MySQLSchema.stringifyFn(value:Object, spaces:Number):String`\n\n\n\n**Description**:  Like `JSON.stringify`, but with a replacer that \nconverts to JavaScript instead, accepting `Function`, `RegExp`\nand `Date` objects as native data.\n\n\n\n\n\n\n## Issues\n\nPlease, report issues and suggestions [here](https://github.com/allnulled/mysql-schema/issues).\n\n## License\n\nThis project is licensed under [WTFPL or What The Fuck Public License](http://www.wtfpl.net/), which means 'do what you want with it'.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fmysql-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Fmysql-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fmysql-schema/lists"}