New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mysql-fill

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-fill - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

index.js

@@ -1,1 +0,1 @@

module.exports = require('./src');
module.exports = require('./src')();
{
"name": "mysql-fill",
"version": "0.0.1",
"version": "0.0.2",
"description": "Simple Node.js utility to help maintaining compatibility between MySQL databases.",

@@ -5,0 +5,0 @@ "main": "index.js",

# mysql-fill
Simple Node.js utility to help maintaining compatibility between MySQL databases.
This little program helps you to maintain the compatibility between MySQL databases by comparing their structure with one specified in a JSON file: if it finds a table, column or constraint (primary key, foreign key, unique and index) that is not described in the JSON file, it gets added to the database.
This program does not perform alterations or deletions - it will only "expand" the databases, in order to avoid conflicts with current versions.
Obs: conflict with 'unique' constraints may occur, if they are specified in the JSON structure but the tables are holding duplicate values.
To install it, use npm:
```bash
$ npm install mysql-fill
```
And to run it, simply use node, passing the 2 configuration files (their structure is described below) as arguments:
```bash
$ node ./mysql-fill ./connection.json ./structure.json
```
The configuration files have the following structure:
```javascript
connection.json - Describes how to connect to the database
{
host: string, // Host
user: string, // Your username
password: string, // Your password
database: string, // Name of the database
connectTimeout: number // Recommended: 10000
}
```
Example:
```javascript
{
"host": "192.168.0.1",
"user": "root",
"password": "password",
"database": "myDatabase",
"connectTimeout": 10000
}
```
structure.json - Describes the structure of the database
```javascript
[
{ // Represents a table
name: string, // Name for the table
description?: string, // Description (optional, not used for queries)
disabled?: boolean, // If true, the table will be ignored
columns: [{ // List of columns
name: string, // Name of the column
type: string, // Type (use the same name as in MySQL: int, varchar, etc)
null?: boolean, // Is the column nullable?
disabled?: boolean, // If true, the column will be ignored
size?: number, // Size of the data type (like varchar(20))
autoIncrement?: boolean, // True for auto-increment
primaryKey?: boolean // Is this field a primary key?
}],
foreignKeys?: [{ // Foreign keys in this table
column: string, // Name of the local column
referenceTable: string, // Name of the table to be referenced
referenceColumn: string, // Name of the column to be referenced (in the referenced table)
onDelete?: string, // ON DELETE action (setNull, restrict, cascade, or noAction)
onUpdate?: string // ON UPDATE actin (setNull, restrict, cascade, or noAction)
}],
unique?: [string], // List of unique columns (by name)
index?: [string] // List of index columns (by name)
}
]
```
Example:
```javascript
[
{
"name": "User",
"description": "This table has the users",
"disabled": false,
"columns": [{
"name": "id",
"type": "int",
"null": false,
"autoIncrement": true,
"primaryKey": true
}, {
"name": "name",
"type": "varchar",
"size": 30,
"null": true
}],
"unique": ["name"],
"index": ["id"]
}, {
"name": "Company",
"description": "This table has the companies",
"disabled": false,
"columns": [{
"name": "id",
"type": "int",
"null": false,
"autoIncrement": true,
"primaryKey": true
}, {
"name": "name",
"type": "varchar",
"size": 30,
"null": true
}, {
"name": "owner",
"type": "int",
"null": false
}],
"foreignKeys": [{
"column": "owner",
"referenceTable": "User",
"referenceColumn": "id",
"onDelete": "restrict",
"onUpdate": "noAction"
}],
"unique": ["name"],
"index": ["id", "name"]
}
]
```

@@ -13,7 +13,2 @@ [

}, {
"name": "gender",
"type": "int",
"size": 1,
"null": true
}, {
"name": "name",

@@ -23,10 +18,5 @@ "type": "varchar",

"null": true
}, {
"name": "email",
"type": "varchar",
"size": 20,
"null": false
}],
"unique": ["email", "name"],
"index": ["id", "email"]
"unique": ["name"],
"index": ["id"]
}, {

@@ -43,7 +33,2 @@ "name": "Company",

}, {
"name": "description",
"type": "varchar",
"size": 70,
"null": true
}, {
"name": "name",

@@ -67,38 +52,3 @@ "type": "varchar",

"index": ["id", "name"]
}, {
"name": "Post",
"description": "Users have posts, when a user is deleted, the posts are deleted as well",
"disabled": false,
"columns": [{
"name": "id",
"type": "int",
"null": false,
"autoIncrement": true,
"primaryKey": true
}, {
"name": "author",
"type": "int",
"null": false
}, {
"name": "content",
"type": "varchar",
"size": 1024
}, {
"name": "company",
"type": "int",
"size": 11
}],
"foreignKeys": [{
"column": "author",
"referenceTable": "User",
"referenceColumn": "id",
"onDelete": "cascade"
}, {
"column": "company",
"referenceTable": "Company",
"referenceColumn": "id",
"onDelete": "cascade"
}],
"index": ["id", "author"]
}
]
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc