1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-12 04:23:09 +02:00

updating typeorm, creating manual scheme update script

This commit is contained in:
Patrik J. Braun 2018-01-20 20:36:38 -05:00
parent 5a1c7030df
commit 83698541be
5 changed files with 78 additions and 36 deletions

View File

@ -9,13 +9,14 @@ import {SharingEntity} from "./enitites/SharingEntity";
import {DataBaseConfig, DatabaseType} from "../../../common/config/private/IPrivateConfig";
import {PasswordHelper} from "../PasswordHelper";
import {ProjectPath} from "../../ProjectPath";
import {VersionEntity} from "./enitites/VersionEntity";
export class SQLConnection {
private static VERSION: number = 1;
constructor() {
}
private static connection: Connection = null;
@ -30,11 +31,13 @@ export class SQLConnection {
UserEntity,
PhotoEntity,
DirectoryEntity,
SharingEntity
SharingEntity,
VersionEntity
];
options.synchronize = true;
// options.logging = "all";
options.synchronize = false;
// options.logging = "all";
this.connection = await createConnection(options);
await SQLConnection.sync(this.connection);
}
return this.connection;
@ -51,15 +54,38 @@ export class SQLConnection {
UserEntity,
PhotoEntity,
DirectoryEntity,
SharingEntity
SharingEntity,
VersionEntity
];
options.synchronize = true;
//options.logging = "all";
options.synchronize = false;
// options.logging = "all";
const conn = await createConnection(options);
await SQLConnection.sync(conn);
await conn.close();
return true;
}
private static async sync(connection: Connection) {
let version = null;
try {
version = await connection.getRepository(VersionEntity).findOne();
} catch (ex) {
}
if (version && version.version == SQLConnection.VERSION) {
return;
}
if (!version) {
version = new VersionEntity();
}
version.version = SQLConnection.VERSION;
await connection.dropDatabase();
await connection.synchronize();
await connection.getRepository(VersionEntity).save(version);
}
public static async init(): Promise<void> {
const connection = await this.getConnection();
let userRepository = connection.getRepository(UserEntity);

View File

@ -1,6 +1,10 @@
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "typeorm";
import {
CameraMetadata, GPSMetadata, ImageSize, PhotoDTO, PhotoMetadata,
CameraMetadata,
GPSMetadata,
ImageSize,
PhotoDTO,
PhotoMetadata,
PositionMetaData
} from "../../../../common/entities/PhotoDTO";
import {DirectoryEntity} from "./DirectoryEntity";

View File

@ -0,0 +1,12 @@
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export class VersionEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
version: number;
}

View File

@ -35,11 +35,11 @@ gulp.task('build-frontend', function (done) {
return f.split(".")[1]
});
var tasks = [];
createFornendTask('build-frontend default', "ng build --aot -prod --output-path=./release/dist --no-progress");
tasks.push('build-frontend default');
createFornendTask('build-frontend-release default', "ng build --aot -prod --output-path=./release/dist --no-progress");
tasks.push('build-frontend-release default');
for (var i = 0; i < files.length; i++) {
createFornendTask('build-frontend ' + languages[i], "ng build --aot -prod --output-path=./release/dist/" + languages[i] + " --no-progress --locale " + languages[i] + " --i18n-format xlf --i18n-file frontend/locale/" + files[i] + " --missing-translation warning");
tasks.push('build-frontend ' + languages[i]);
createFornendTask('build-frontend-release ' + languages[i], "ng build --aot -prod --output-path=./release/dist/" + languages[i] + " --no-progress --locale " + languages[i] + " --i18n-format xlf --i18n-file frontend/locale/" + files[i] + " --missing-translation warning");
tasks.push('build-frontend-release ' + languages[i]);
}
tasks.push(function () {
done();
@ -97,11 +97,11 @@ var simpleBuild = function (isProd) {
if (isProd) {
cmd += " -prod "
}
createFornendTask('build-frontend-dev default', cmd + "--output-path=./dist --no-progress");
tasks.push('build-frontend-dev default');
createFornendTask('build-frontend default', cmd + "--output-path=./dist --no-progress");
tasks.push('build-frontend default');
for (var i = 0; i < files.length; i++) {
createFornendTask('build-frontend-dev ' + languages[i], cmd + "--output-path=./dist/" + languages[i] + " --no-progress --locale " + languages[i] + " --i18n-format xlf --i18n-file frontend/locale/" + files[i] + " --missing-translation warning");
tasks.push('build-frontend-dev ' + languages[i]);
createFornendTask('build-frontend ' + languages[i], cmd + "--output-path=./dist/" + languages[i] + " --no-progress --locale " + languages[i] + " --i18n-format xlf --i18n-file frontend/locale/" + files[i] + " --missing-translation warning");
tasks.push('build-frontend ' + languages[i]);
}
tasks.push(function () {
done();

View File

@ -35,30 +35,30 @@
"jimp": "0.2.28",
"locale": "0.1.0",
"mysql": "2.15.0",
"reflect-metadata": "0.1.10",
"reflect-metadata": "0.1.12",
"sqlite3": "3.1.13",
"ts-exif-parser": "0.1.23",
"ts-node-iptc": "1.0.9",
"typeconfig": "1.0.6",
"typeorm": "0.1.8",
"typeorm": "0.1.11",
"winston": "2.4.0"
},
"devDependencies": {
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^5.2.0",
"@angular/cli": "1.6.4",
"@angular/common": "~5.2.0",
"@angular/compiler": "~5.2.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/core": "~5.2.0",
"@angular/forms": "~5.2.0",
"@angular/http": "~5.2.0",
"@angular/language-service": "^5.2.0",
"@angular/platform-browser": "~5.2.0",
"@angular/platform-browser-dynamic": "~5.2.0",
"@angular/router": "~5.2.0",
"@angular/animations": "^5.2.1",
"@angular/cli": "1.6.5",
"@angular/common": "~5.2.1",
"@angular/compiler": "~5.2.1",
"@angular/compiler-cli": "^5.2.1",
"@angular/core": "~5.2.1",
"@angular/forms": "~5.2.1",
"@angular/http": "~5.2.1",
"@angular/language-service": "^5.2.1",
"@angular/platform-browser": "~5.2.1",
"@angular/platform-browser-dynamic": "~5.2.1",
"@angular/router": "~5.2.1",
"@types/bcryptjs": "^2.4.1",
"@types/chai": "^4.1.0",
"@types/chai": "^4.1.1",
"@types/cookie-session": "^2.0.34",
"@types/express": "^4.11.0",
"@types/gm": "^1.17.33",
@ -69,7 +69,7 @@
"@types/winston": "^2.3.7",
"bootstrap": "^3.3.7",
"chai": "^4.1.2",
"codelyzer": "~4.0.2",
"codelyzer": "~4.1.0",
"core-js": "^2.5.3",
"ejs-loader": "^0.3.0",
"gulp": "^3.9.1",
@ -78,7 +78,7 @@
"gulp-zip": "^4.1.0",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
"jasmine-core": "^2.8.0",
"jasmine-core": "^2.9.1",
"jasmine-spec-reporter": "~4.2.1",
"jw-bootstrap-switch-ng2": "1.0.10",
"karma": "^2.0.0",
@ -90,11 +90,11 @@
"karma-remap-istanbul": "^0.6.0",
"karma-systemjs": "^0.16.0",
"merge2": "^1.2.1",
"mocha": "^4.1.0",
"mocha": "^5.0.0",
"ng2-cookies": "^1.0.12",
"ng2-slim-loading-bar": "^4.0.0",
"ng2-toastr": "^4.1.2",
"ngx-bootstrap": "^2.0.0-rc.0",
"ngx-bootstrap": "^2.0.0",
"ngx-clipboard": "^9.1.2",
"phantomjs-prebuilt": "^2.1.16",
"protractor": "^5.2.2",