{"id":14969116,"url":"https://github.com/mwpastore/ember-cli-deploy-mysql","last_synced_at":"2025-10-26T06:31:05.339Z","repository":{"id":57153252,"uuid":"47729471","full_name":"mwpastore/ember-cli-deploy-mysql","owner":"mwpastore","description":"Deploy your Ember.js index to MySQL","archived":false,"fork":false,"pushed_at":"2017-07-27T22:46:11.000Z","size":21,"stargazers_count":5,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T03:48:31.766Z","etag":null,"topics":["ember-addon","ember-cli-deploy","mariadb","mysql"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mwpastore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-10T01:17:30.000Z","updated_at":"2016-12-14T15:04:31.000Z","dependencies_parsed_at":"2022-09-06T08:52:12.767Z","dependency_job_id":null,"html_url":"https://github.com/mwpastore/ember-cli-deploy-mysql","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwpastore%2Fember-cli-deploy-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwpastore%2Fember-cli-deploy-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwpastore%2Fember-cli-deploy-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwpastore%2Fember-cli-deploy-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mwpastore","download_url":"https://codeload.github.com/mwpastore/ember-cli-deploy-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238276061,"owners_count":19445340,"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":["ember-addon","ember-cli-deploy","mariadb","mysql"],"created_at":"2024-09-24T13:41:09.116Z","updated_at":"2025-10-26T06:30:59.993Z","avatar_url":"https://github.com/mwpastore.png","language":"JavaScript","readme":"# ember-cli-deploy-mysql\n\n## This plugin is deprecated. Please use [ember-cli-deploy-sql](https://github.com/mwpastore/ember-cli-deploy-sql) instead!\n\n[![npm version](https://badge.fury.io/js/ember-cli-deploy-mysql.svg)](https://badge.fury.io/js/ember-cli-deploy-mysql) [![](https://ember-cli-deploy.github.io/ember-cli-deploy-version-badges/plugins/ember-cli-deploy-mysql.svg)](http://ember-cli-deploy.github.io/ember-cli-deploy-version-badges/)\n\nThis plugin, lovingly cribbed from [ember-cli-deploy-redis][8], uploads the\ncontents of a file, presumably index.html, to a specified MySQL table.  Systems\ncompatible with the MySQL protocol such as MariaDB are also supported.\n\nMore often than not this plugin will be used in conjunction with the [lightning\nmethod of deployment][1] where the Ember.js application assets will be served\nfrom S3 and the index.html file will be served from a key-value store of some\nkind; in this case, a MySQL table.  However, it can be used to upload the\ncontents of any file.\n\n## What is an ember-cli-deploy plugin?\n\nA plugin is an addon that can be executed as a part of the ember-cli-deploy\npipeline. A plugin will implement one or more of the ember-cli-deploy's\npipeline hooks.\n\nFor more information on what plugins are and how they work, please refer to the\n[Plugin Documentation][2].\n\n## Why would I use this instead of ember-cli-deploy-redis?\n\nThat's a great question.  Redis is a much better solution for this kind of\nproblem and you can do neat things like serve directly from NGINX.  MySQL, on\nthe other hand, isn't really set up well for key-value storage and retrieval,\nand it ends up being a somewhat clumsy solution.\n\nIn our case, we were only using Redis for this particular function, so it\nseemed overkill to be running the service (and maintaining a connection pool to\nit in our Ruby application).  Also, our API responses (including the Ember.js\nindex) are already being cached (thanks to a caching reverse proxy), so talk\nabout redundant layers!  It makes more sense for us, for now, to serve the\nindex from MySQL and let our reverse proxy cache it.  Perhaps your situation is\nsimilar?\n\n## Quick Start\n\nTo get up and running quickly, do the following:\n\n- Ensure [ember-cli-deploy-build][4] is installed and configured.\n\n- Install this plugin:\n\n```sh\n$ ember install ember-cli-deploy-mysql\n```\n\n- Place the following configuration into `config/deploy.js`:\n\n```javascript\nENV.mysql = {\n  user: '\u003cyour-mysql-user\u003e',\n  password: '\u003cyour-mysql-password\u003e',\n  database: '\u003cyour-mysql-database\u003e'\n}\n```\n\n- Run the pipeline:\n\n```sh\n$ ember deploy \u003cenvironment\u003e\n```\n\n## Installation\n\nRun the following command in your terminal:\n\n```sh\nember install ember-cli-deploy-mysql\n```\n\n## ember-cli-deploy Hooks Implemented\n\nFor detailed information on what plugin hooks are and how they work, please\nrefer to the [Plugin Documentation][2].\n\n- `configure`\n- `upload`\n- `willActivate`\n- `activate`\n- `didDeploy`\n\n## Configuration Options\n\nFor detailed information on how configuration of plugins works, please refer to\nthe [Plugin Documentation][2].\n\n### host\n\nThe MySQL host. If [url](#url) is defined, then this option is not needed.\n\n*Default:* `'localhost'`\n\n### port\n\nThe MySQL port. If [url](#url) is defined, then this option is not needed.\n\n*Default:* `3306` or `context.tunnel.srcPort` if present (set by\n[ember-cli-deploy-ssh-tunnel][7])\n\n### database\n\nThe MySQL database name. If [url](#url) is defined, then this option is not\nneeded.\n\n### user\n\nThe MySQL user name. If [url](#url) is defined, then this option is not needed.\n\n### password\n\nThe MySQL password. If [url](#url) is defined, then this option is not needed.\n\nYou can create a `.env.deploy.\u003cenvironment\u003e` file in your project root to store\n\"secrets\" like database passwords (e.g. `MYSQL_PASSWORD=bananasplit`) and\nreference these values in your `config/deploy.js` as `process.env.\u003ckey\u003e` (e.g.\n`process.env.MYSQL_PASSWORD`).  You should add any and all such \"secret\" files\nto your `.gitignore` to prevent them from being inadvertently checked in!\n\n### url\n\nA MySQL connection URL:\n\n*Example:* `'mysql://some-user:some-password@some-host/some-db'`\n\nSee the [node-mysql][3] documentation for more information.\n\n### filePattern\n\nA file matching this pattern will be uploaded to the MySQL table.\n\n*Default:* `'index.html'`\n\n### distDir\n\nThe root directory where the file matching `filePattern` will be searched for.\nBy default, this option will use the `distDir` property of the deployment\ncontext.\n\n*Default:* `context.distDir`\n\n### tableName\n\nThe name of the table to be used to store the revision keys and file contents\nin MySQL.  By default this option will use the `project.name()` property\nfrom the deployment context.\n\n*Default:* `context.project.name().replace(/-/g, '_') + '_bootstrap'`\n\nThe table is created in your database automatically on the initial deploy, so\nyour MySQL user will need create table privileges!  Here is the DDL in case you\nwant to create it separately, in advance:\n\n```sql\nCREATE TABLE `your_project_name_bootstrap` (\n  `id` int AUTO_INCREMENT,\n  `key` varchar(255) NOT NULL,\n  `value` text NOT NULL,\n  `gitsha` binary(20), -- reserved for future use\n  `deployer` varchar(255), -- reserved for future use\n  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `NATURAL` (`key`)\n);\n```\n\nWhich should create a table that looks like:\n\n| Field      | Type         | Null | Key | Default           | Extra          |\n| ---------- | ------------ | ---- | --- | ----------------- | -------------- |\n| id         | int(11)      | NO   | PRI | NULL              | auto_increment |\n| key        | varchar(255) | NO   | UNI | NULL              |                |\n| value      | text         | NO   |     | NULL              |                |\n| gitsha     | binary(20)   | YES  |     | NULL              |                |\n| deployer   | varchar(255) | YES  |     | NULL              |                |\n| created_at | timestamp    | NO   |     | CURRENT_TIMESTAMP |                |\n\n### revisionKey\n\nThe unique revision number for the version of the file being uploaded to MySQL.\nBy default this option will use either the `revisionKey` passed in from the\ncommand line or the `revisionData.revisionKey` property from the deployment\ncontext.\n\n*Default:* `context.commandLineArgs.revisionKey || context.revisionData.revisionKey`\n\n### allowOverwrite\n\nA flag to specify whether the revision should be overwritten if it already\nexists in the MySQL table.\n\n*Default:* `false`\n\n### deployClient\n\nThe MySQL client to be used to upload files to the MySQL table.  By default\nthis option will use a new instance of the [MySQL][3] client.  This allows for\ninjection of a mock client for testing purposes.\n\n*Default:* `return new MySQL(options)`\n\n### didDeployMessage\n\nA message that will be displayed after the file has been successfully uploaded\nto MySQL. By default this message will only display if the revision for\n`revisionData.revisionKey` of the deployment context has been activated.\n\n### maxRecentUploads\n\nThe maximum number of recent revisions to keep in the MySQL table.\n\n*Default:* `10`\n\n## Activation\n\nAs well as uploading a file to MySQL, *ember-cli-deploy-mysql* has the ability\nto mark a revision of a deployed file as `current`.  This is most commonly used\nin the [lightning method of deployment][1] whereby an index.html file is pushed\nto a key-value store and then served to the user by the application.\n\nThe application could be configured to return any existing revision of the\nindex.html file as requested by a query parameter.  However, the revision\nmarked as the currently active revision would be returned if no query parameter\nis present.  For more detailed information on this method of deployment please\nrefer to the [ember-cli-deploy-lightning-pack README][1].\n\n### How do I activate a revision?\n\nA user can activate a revision by either:\n\n- Passing a command line argument to the `deploy` command:\n\n```sh\n$ ember deploy \u003cenvironment\u003e --activate\n```\n\n- Running the `deploy:activate` command:\n\n```sh\n$ ember deploy:activate \u003cenvironment\u003e --revision=\u003crevision-key\u003e\n```\n\n- Setting the `activateOnDeploy` flag in `config/deploy.js`\n\n```javascript\nENV.pipeline = {\n  activateOnDeploy: true\n}\n```\n\n### What does activation do?\n\nWhen *ember-cli-deploy-mysql* uploads a file to MySQL, it uploads to the table\ndefined by the `tableName` config property, with a key defined by the\n`revisionKey` config property.  So if there have been three revisons deployed,\nMySQL might look something like this:\n\n```sh\n$ mysql -u root foo\n\nMariaDB [foo]\u003e select `key`, left(`value`, 10) from bar_bootstrap;\n+----------------------------------+-------------------+\n| key                              | left(`value`, 10) |\n+----------------------------------+-------------------+\n| cc9d9af44ad70f4a6732c1c13deb246e | \u003c!DOCTYPE         |\n| 071be39412920947613c00d680b8e9c0 | \u003c!DOCTYPE         |\n| d56d56274aac91e229fa69f34f4cf81d | \u003c!DOCTYPE         |\n+----------------------------------+-------------------+\n```\n\nActivating a revison would add a new entry to the MySQL table pointing to the\nselected revision:\n\n```sh\n$ ember deploy:activate production --revision=cc9d9af44ad70f4a6732c1c13deb246e\n✔ Activated revision `cc9d9af44ad70f4a6732c1c13deb246e`\n$ mysql -u root foo\n\nMariaDB [foo]\u003e select `key`, left(`value`, 10) from bar_bootstrap;\n+----------------------------------+-------------------+\n| key                              | left(`value`, 10) |\n+----------------------------------+-------------------+\n| cc9d9af44ad70f4a6732c1c13deb246e | \u003c!DOCTYPE         |\n| 071be39412920947613c00d680b8e9c0 | \u003c!DOCTYPE         |\n| d56d56274aac91e229fa69f34f4cf81d | \u003c!DOCTYPE         |\n| current                          | cc9d9af44a        |\n+----------------------------------+-------------------+\n```\n\n### When does activation occur?\n\nActivation occurs during the `activate` hook of the pipeline.  By default,\nactivation is turned off and must be explicitly enabled by one of the three\nmethods described above.\n\n## What if my MySQL server isn't publicly accessible?\n\nNot to worry!  Just install the handy-dandy [ember-cli-deploy-ssh-tunnel][7]\nplugin:\n\n```\nember install ember-cli-deploy-ssh-tunnel\n```\n\nAnd set up your `config/deploy.js` similar to the following:\n\n```js\nENV = {\n  mysql: {\n    database: 'your-mysql-database',\n    user: 'your-mysql-user',\n    password: process.env.MYSQL_PASSWORD\n  },\n  'ssh-tunnel': {\n    username: 'your-ssh-username',\n    host: 'remote-mysql-host'\n  }\n}\n```\n\n### What if my MySQL server is only accessible *from* my remote server?\n\nSometimes you need to SSH into a server (a \"bastion\" server) and then run\n`mysql` or similar from there.  This is really common if you're using RDS on\nAWS, for instance.  We've got you covered there, too: just set your SSH\ntunnel host to the bastion server and tell the tunnel to use your MySQL server\nas the destination host, like so:\n\n```js\nENV = {\n  mysql: {\n    database: 'your-mysql-database',\n    user: 'your-mysql-user',\n    password: process.env.MYSQL_PASSWORD\n  },\n  'ssh-tunnel': {\n    username: 'your-ssh-username',\n    host: 'remote-mysql-client',\n    dstHost: 'remote-mysql-server'\n  }\n}\n```\n\n## Prerequisites\n\nThe following properties are expected to be present on the deployment `context`\nobject:\n\n- `distDir` (provided by [ember-cli-deploy-build][4])\n- `project.name()` (provided by [ember-cli-deploy][5])\n- `revisionData.revisionKey` (provided by [ember-cli-deploy-revision-data][6])\n- `commandLineArgs.revisionKey` (provided by [ember-cli-deploy][5])\n- `deployEnvironment` (provided by [ember-cli-deploy][5])\n\nThe following properties are used if present on the deployment `context`\nobject:\n\n- `tunnel.srcPort` (provided by [ember-cli-deploy-ssh-tunnel][7])\n\n[1]: https://github.com/lukemelia/ember-cli-deploy-lightning-pack \"ember-cli-deploy-lightning-pack\"\n[2]: http://ember-cli.github.io/ember-cli-deploy/plugins \"Plugin Documentation\"\n[3]: https://github.com/felixge/node-mysql \"MySQL client\"\n[4]: https://github.com/ember-cli-deploy/ember-cli-deploy-build \"ember-cli-deploy-build\"\n[5]: https://github.com/ember-cli/ember-cli-deploy \"ember-cli-deploy\"\n[6]: https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data \"ember-cli-deploy-revision-data\"\n[7]: https://github.com/ember-cli-deploy/ember-cli-deploy-ssh-tunnel \"ember-cli-deploy-ssh-tunnel\"\n[8]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis \"ember-cli-deploy-redis\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwpastore%2Fember-cli-deploy-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmwpastore%2Fember-cli-deploy-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwpastore%2Fember-cli-deploy-mysql/lists"}