Skip to content

Instantly share code, notes, and snippets.

Avatar

MatsuAki(Hideaki Matsuo) matsuaki-jp

View GitHub Profile
@matsuaki-jp
matsuaki-jp / package.json
Created Aug 21, 2020
sequelize do migration package.json
View package.json
"scripts": {
"databaseBuild": "tsc --project ./database/tsconfig.json",
"migration:up": "npm run databaseBuild && ts-node ./database/config/doMigration.ts up"
}
View tsconfig.json
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext",
"ES6"
],
"typeRoots": [
"node_modules/@types"
@matsuaki-jp
matsuaki-jp / settings.ts
Created Aug 21, 2020
sequelize with ts settings.ts
View settings.ts
import {Dialect} from 'sequelize'
interface ConnectionConfig {
dbname:string;
dbUsername:string
dbPassword:string
dbDialect:Dialect
dbSchema?:string
dbPort:number
dbHost:string
localhost:string
@matsuaki-jp
matsuaki-jp / doMigration.ts
Last active Aug 30, 2020
sequelize do migration
View doMigration.ts
import { Writable } from 'stream';
import { Socket } from 'net';
import { connectionConfig } from './settings'
import { Client } from 'ssh2';
import { Sequelize } from 'sequelize';
import { Umzug } from 'umzug';
const net = require('net');
/**
* 処理成功時
View 20200726100026-create-hello.ts
'use strict';
import { QueryInterface, DataTypes } from 'sequelize';
module.exports = {
up: async (queryInterface:QueryInterface) => {
await queryInterface.createTable('hellos', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,