Public project to perform migrations on mysql database.

Overview

node-mysql-migrate

Public project to perform migrations on mysql database.

How to run

  1. First step, install the dependency for your project. To make it, to do this you have to run this command:
  npm install node-mysql-migrate

Obs: You need install mysql dependency too.

  1. Create your migrations, example below:
  import { createTable } from 'node-mysql-migrate'

  export default function users(){
      createTable({
          tableName: 'users',
          fields: [
              {
                  name: 'id',
                  type: 'INT',
                  pk: true,
                  isNull: false,
                  increment: true
              },
              {
                  name: 'fullname',
                  type: 'VARCHAR',
                  size: 255,
                  isNull: false
              },
              {
                  name: 'email',
                  type: 'VARCHAR',
                  size: 255,
                  isNull: false
              },
              {
                  name: 'password',
                  type: 'VARCHAR',
                  size: 255,
                  isNull: false
              },
              {
                  name: 'typeAccess_id',
                  type: 'INT', 
                  fk: {
                      tableName: 'typeAccess',
                      fieldName: 'id'
                  },
                  isNull: false
              },
              {
                  name: 'created_at',
                  type: 'DATETIME',
                  default: 'NOW()',
                  isNull: false
              }
          ]
      })
  }
  1. Create the migration data source, example below:
  import MigrationDataSource from 'node-mysql-migrate'
  import users from './migrations/users'
  import typeAccess from './migrations/typeAccess'

  export default new MigrationDataSource({
      db_config: {    
          host     : '...yourHost',
          port     : 3306, //your port
          user     : '...yourUser',
          password : '...yourPass',
          database : '...yourDatabase',
      },
      migrations: [users, typeAccess]  
  })

Obs: In the 'migrations' field you must add your migrations.

  1. In the "index" file of your project import and run the migration configuration.
   import express from 'express'
   import MigrationDataSource from './database/migration'
   
   MigrationDataSource
   
   const app = express()
   ...
   app.listen(3333, () => console.log('Server is running on port: 3333'))

That's all folks.

You might also like...

In this repository, I try to perform a mainnet fork and then simulate popular smart contract exploits on various DEFI Protocols using Hardhat Framework.

defiHacks_via_Hardhat 1. Alchemix Access Control Bug Any user could have called setWhitelist() to give an attacker the ability to call the harvest fun

Dec 27, 2022

Node.js Express + MySQL vulnerable boilerplate project

Node.js Express + MySQL vulnerable boilerplate project

Node.js Express + MySQL vulnerable boilerplate project

Sep 16, 2022

Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

Oct 6, 2022

Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! dbSpy is an open-source data modeling tool to facilitate relational database development. Key F

Dec 22, 2022

This project scans yandex disk folders that are open to public sharing and allows you to download their contents.

This project scans yandex disk folders that are open to public sharing and allows you to download their contents.

kitapbar.com Development start mongodb server docker-compose -f docker-compose.dev.yaml up -d yandex service cd services/yandex create a .env file by

Oct 15, 2022

Use real-time computing technology and web technology to build a big data Kanban l to solve the problem. Among them, practical technologies include MySQL, Kafka, Flink, Redis, Flask and Echarts

Use real-time computing technology and web technology to build a big data Kanban l to solve the problem. Among them, practical technologies include MySQL, Kafka, Flink, Redis, Flask and Echarts

实时计算(English Version) 运用实时计算技术、Web 技术构建一个大数据看板来解决问题。其中实用技术包括Mysql、Kafka、Flink、Redis、Flask和Echarts 目录 1.问题需求 2.方案分析 3.安装环境 4.环境启动命令和运行代码的方法 5.代码目录结构说明

Jan 8, 2022

practice site to utilize node.js, Express, and mySQL

fishing_site practice site to utilize node.js, Express, and mySQL Run Locally create local instance of MySQL database. Run DB/fishing_Schema.sql to cr

Jan 22, 2022

A dockerized express mysql starter using typescript which iclude user management

A dockerized express mysql starter using typescript which iclude user management

Jan 26, 2022

A Restaurant (Table) Reservation API built with Node, TypeScript, Express, TypeORM, a MySQL DB, all running on Docker containers

Restaurant (Table) Reservation API A simple API for reserving tables at a restaurant. The API is based on the REST architectural style and uses Node.j

Oct 5, 2022
Owner
Tiago Murilo
technology enthusiast!
Tiago Murilo
Blog application api in Node.js express.js sequelize ORM and MYSQL Database

Node Express Mysql Sequelise Blog System Api Node api with express mysql sequelise Usage To get started with this api follow the steps below $ git clo

Kaddu Livingstone 6 Nov 9, 2022
This project is a web application that enables users to add, edit and remove tasks they intend to perform. Built with JavaScript, HTML, and CSS.

TO DO List Unit testing using jest Create the to-do List project with webpack. Ultimately, the user should be able to add an item and delete the item

Afolabi Akorede 10 Jul 26, 2022
With this File Manager prepared for PHP/Js, you can perform all file operations on your server without any problems.

FileManager With this File Manager prepared for PHP/Js, you can perform all file operations on your server without any problems. Instead of downloadin

Tanzer Demir 4 Sep 23, 2022
A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview ?? It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Yazan Zoghbi 2 Apr 22, 2022
Utility for authorizing user in a connected app, creating JWT to authenticate against it, and perform a sample callout.

Question: What is this for? Answer: When configuring a Salesforce Connected app to use certificates to authenticate you will use JSON Web Tokens to a

null 4 Jun 15, 2022
A crawler that crawls the site's internal links, fetching information of interest to any SEO specialist to perform appropriate analysis on the site.

Overview ?? It is a module that crawls sites and extracts basic information on any web page of interest to site owners in general, and SEO specialists

Yazan Zoghbi 2 Apr 22, 2022
mock APIs, intelligently, with context, and perform other stuff as well

@sasta-sa/project mock APIs, intelligently, with context, and perform other stuff as well ?? Setting up Clone the project git clone https://github.com

null 5 Jan 27, 2022
A minimalist Javascript library to perform AJAX POST and GET Request.

minAjax.js A minimalist Javascript library to perform AJAX POST and GET Request. #Check Pretty Documentation http://flouthoc.github.io/minAjax.js/ #Us

null 6 Apr 27, 2021
Perform queries on the current graph and batch process on the results.

logseq-plugin-batch-op 对当前库进行查询并对查询结果进行批量操作。 Perform queries on the current graph and batch process on the results. 使用展示 (Usage) 批量删除 (Batch Delete) 批

Seth Yuan 22 Dec 1, 2022
This is a web application that enables users to add, edit and remove tasks they intend to perform. Built with JavaScript, HTML, and CSS.

TODO LIST It list everything that you have to do, with the most important tasks at the top of the list, and the least important tasks at the bottom. B

Josphat Kiploman 7 Sep 16, 2022