Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Successfully wrapped underlying typeorm connection to allow raw sql queries in the same node-mysql style. Migrations also now work. Automatic migration generation seems a little buggy (it always tries to recreate indexes). Not the end of the world-- most migrations inevitably need to be written manually anyway.
- Loading branch information
Jaiden Mispy
committed
Aug 16, 2018
1 parent
990b56b
commit fdc863a
Showing
9 changed files
with
97 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const {DB_HOST, DB_NAME, DB_USER, DB_PASS, DB_PORT} = require('./dist/src/settings') | ||
|
||
module.exports = { | ||
"type": "mysql", | ||
"host": DB_HOST, | ||
"port": DB_PORT, | ||
"username": DB_USER, | ||
"password": DB_PASS, | ||
"database": DB_NAME, | ||
"entities": ["dist/src/model/**/*.js"], | ||
"migrations": ["dist/src/migration/**/*.js"], | ||
"cli": { | ||
"entitiesDir": "src/model", | ||
"migrationsDir": "src/migration" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
|
||
export class Typeorm1534413949262 implements MigrationInterface { | ||
|
||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
await queryRunner.query("ALTER TABLE `user_invitations` DROP FOREIGN KEY `user_invitations_user_id_29cac16b_fk_users_id`"); | ||
await queryRunner.query("ALTER TABLE `charts` DROP FOREIGN KEY `charts_last_edited_by_791cce39_fk_users_name`"); | ||
await queryRunner.query("ALTER TABLE `charts` DROP FOREIGN KEY `charts_published_by_e3f4abdf_fk_users_name`"); | ||
await queryRunner.query("ALTER TABLE `user_invitations` DROP COLUMN `user_id`"); | ||
await queryRunner.query("ALTER TABLE `users` DROP COLUMN `last_login`"); | ||
await queryRunner.query("ALTER TABLE `user_invitations` DROP COLUMN `status`"); | ||
await queryRunner.query("UPDATE users SET full_name='' WHERE full_name IS NULL"); | ||
await queryRunner.query("ALTER TABLE `users` CHANGE `full_name` `full_name` varchar(255) NOT NULL DEFAULT ''"); | ||
await queryRunner.query("ALTER TABLE `users` CHANGE `is_active` `is_active` tinyint NOT NULL DEFAULT 1"); | ||
await queryRunner.query("ALTER TABLE `users` CHANGE `is_superuser` `is_superuser` tinyint NOT NULL DEFAULT 0"); | ||
await queryRunner.query("ALTER TABLE `users` CHANGE `created_at` `created_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `users` CHANGE `updated_at` `updated_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `user_invitations` CHANGE `valid_till` `valid_till` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `user_invitations` CHANGE `created_at` `created_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `user_invitations` CHANGE `updated_at` `updated_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` CHANGE `last_edited_at` `last_edited_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` CHANGE `published_at` `published_at` datetime NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` CHANGE `created_at` `created_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` CHANGE `updated_at` `updated_at` datetime NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` CHANGE `starred` `starred` tinyint NOT NULL"); | ||
await queryRunner.query("ALTER TABLE `charts` ADD CONSTRAINT `FK_ebe44242cb70398fcb5af3c9316` FOREIGN KEY (`last_edited_by`) REFERENCES `users`(`name`)"); | ||
await queryRunner.query("ALTER TABLE `charts` ADD CONSTRAINT `FK_b3879b5deca71fae207d0365257` FOREIGN KEY (`published_by`) REFERENCES `users`(`name`)"); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
throw new Error("Unsupported") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters