mssql -> postgres

This commit is contained in:
BillMills 2019-06-21 13:38:27 -04:00
parent cdf9a12c62
commit 796318a319
5 changed files with 25 additions and 36 deletions

View File

@ -1,13 +1,17 @@
var Sequelize = require('sequelize'); var Sequelize = require('sequelize');
var username = 'sa'; var username = 'postgres';
var password = 'DockerCon!!!'; var password = 'DockerCon!!!';
var host = 'bb-db'; var host = 'bb-db';
var dbName = 'BulletinBoard'; var dbName = 'postgres';
var sequelize = new Sequelize(dbName, username, password, { var sequelize = new Sequelize(dbName, username, password, {
dialect: 'mssql', dialect: 'postgres',
host: host, host: host,
port: 1433, port: 5432,
omitNull: true,
define: {
timestamps: false
},
dialectOptions: { dialectOptions: {
requestTimeout: 30000 requestTimeout: 30000
} }

View File

@ -14,7 +14,9 @@
"vue-resource": "^0.1.17", "vue-resource": "^0.1.17",
"tedious": "^2.0.1", "tedious": "^2.0.1",
"sequelize": "^4.20.1", "sequelize": "^4.20.1",
"prom-client": "^10.2.2" "prom-client": "^10.2.2",
"pg": "^7.0.0",
"pg-hstore": "^2.3.3"
}, },
"devDependencies": { "devDependencies": {
"body-parser": "^1.14.1", "body-parser": "^1.14.1",

View File

@ -1,10 +1,5 @@
FROM microsoft/mssql-server-linux:2017-CU1 FROM postgres:9.6
ENV ACCEPT_EULA=Y \ ENV POSTGRES_PASSWORD=DockerCon!!!
MSSQL_SA_PASSWORD=DockerCon!!!
WORKDIR /init COPY init-db.sh /docker-entrypoint-initdb.d/init-db.sh
COPY init-db.* ./
RUN chmod +x ./init-db.sh
RUN /opt/mssql/bin/sqlservr & ./init-db.sh

View File

@ -1,3 +1,11 @@
sleep 30s #!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE TABLE Events(Id SERIAL, Title TEXT, Detail TEXT, Date DATE);
INSERT INTO Events (Title, Detail, Date) VALUES
('Docker for Beginners', 'Introduction to Docker using Node.js', '2017-11-21'),
('Advanced Orchestration', 'Deep dive into Docker Swarm', '2017-12-25'),
('Docker on Windows', 'From 101 to production', '2018-01-01');
EOSQL
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P DockerCon!!! -i init-db.sql

View File

@ -1,20 +0,0 @@
CREATE DATABASE BulletinBoard;
GO
USE BulletinBoard;
CREATE TABLE Events (
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
Title NVARCHAR(50),
Detail NVARCHAR(200),
[Date] DATETIMEOFFSET,
CreatedAt DATETIMEOFFSET NOT NULL,
UpdatedAt DATETIMEOFFSET NOT NULL
);
INSERT INTO Events (Title, Detail, [Date], CreatedAt, UpdatedAt) VALUES
(N'Docker for Beginners', N'Introduction to Docker using Node.js', '2017-11-21', GETDATE(), GETDATE()),
(N'Advanced Orchestration', N'Deep dive into Docker Swarm', '2017-12-25', GETDATE(), GETDATE()),
(N'Docker on Windows', N'From 101 to production', '2018-01-01', GETDATE(), GETDATE());
SELECT * FROM BulletinBoard.dbo.Events;