|
| 1 | +/** |
| 2 | + * Copyright (c) 2021 Gitpod GmbH. All rights reserved. |
| 3 | + * Licensed under the GNU Affero General Public License (AGPL). |
| 4 | + * See License-AGPL.txt in the project root for license information. |
| 5 | + */ |
| 6 | + |
| 7 | +import {MigrationInterface, QueryRunner} from "typeorm"; |
| 8 | + |
| 9 | +export class UpdateExamples1616920059049 implements MigrationInterface { |
| 10 | + |
| 11 | + public async up(queryRunner: QueryRunner): Promise<any> { |
| 12 | + const newEntries = [ |
| 13 | + { url: 'https://github.com/gitpod-io/sveltejs-template', description: 'A project template for Svelte applications', priority: 90 }, |
| 14 | + { url: 'https://github.com/gitpod-io/spring-petclinic', description: 'A Spring sample web application', priority: 70 }, |
| 15 | + { url: 'https://github.com/breatheco-de/python-flask-api-tutorial', description: 'An interactive tutorial about Python Flask', priority: 40 }, |
| 16 | + { url: 'https://github.com/gitpod-io/ruby-on-rails', description: 'A Rails example with PostgreSQL database', priority: 30 }, |
| 17 | + { url: 'https://github.com/gitpod-io/dotnetcore', description: 'A simple .NET Core application example', priority: 20 }, |
| 18 | + { url: 'https://github.com/symfony/demo', description: 'A Symfony demo application', priority: 10 }, |
| 19 | + ] |
| 20 | + // delete old entries |
| 21 | + await queryRunner.query("DELETE FROM d_b_repository_white_list"); |
| 22 | + const insert = `INSERT IGNORE INTO d_b_repository_white_list (url, description, priority) VALUES ${newEntries.map(e=>'(?, ?, ?)').join(', ')}`; |
| 23 | + const values: any[] = []; |
| 24 | + for (const e of newEntries) { |
| 25 | + values.push(e.url, e.description, e.priority); |
| 26 | + } |
| 27 | + await queryRunner.query(insert, values); |
| 28 | + } |
| 29 | + |
| 30 | + public async down(queryRunner: QueryRunner): Promise<any> { |
| 31 | + } |
| 32 | + |
| 33 | +} |
0 commit comments