|
| 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 | +import {MigrationInterface, QueryRunner} from "typeorm"; |
| 7 | + |
| 8 | +export class ExampleRepositories1612448906950 implements MigrationInterface { |
| 9 | + |
| 10 | + public async up(queryRunner: QueryRunner): Promise<any> { |
| 11 | + const oldEntries = [ |
| 12 | + { url: 'https://github.com/gitpod-io/django-locallibrary-tutorial', description: '**Python** - Tutorial "Local Library" website written in Django', priority: 10 }, |
| 13 | + { url: 'https://github.com/gitpod-io/gs-spring-boot.git', description: '**Java** - Building an Application with Spring Boot', priority: 9 }, |
| 14 | + { url: 'https://github.com/gitpod-io/NextSimpleStarter.git', description: '**JavaScript** - Simple PWA boilerplate with Next.js and Redux', priority: 8 }, |
| 15 | + { url: 'https://github.com/gitpod-io/go-gin-app.git', description: '**Go** - A simple web app implemented in Go and Gin', priority: 7 }, |
| 16 | + { url: 'https://github.com/gitpod-io/rails_sample_app', description: '**Ruby on Rails** - Tutorial sample application', priority: 6 }, |
| 17 | + { url: 'https://github.com/gitpod-io/symfony-demo.git', description: '**PHP** - Symfony Demo Application', priority: 5 }, |
| 18 | + { url: 'https://github.com/theia-ide/theia.git', description: '**Typescript** - Deep dive into Gitpod\\\'s open-source IDE, Theia.', priority: 4 } |
| 19 | + ]; |
| 20 | + const newEntries = [ |
| 21 | + { url: 'https://github.com/gitpod-io/sveltejs-template', description: '**JavaScript** – A project template for Svelte applications', priority: 90 }, |
| 22 | + { url: 'https://github.com/eclipse-theia/theia', description: '**TypeScript** – A cloud & desktop IDE framework', priority: 80 }, |
| 23 | + { url: 'https://github.com/breatheco-de/python-flask-api-tutorial', description: '**Python** – An interactive tutorial about Python Flask', priority: 70 }, |
| 24 | + { url: 'https://github.com/prometheus/prometheus', description: '**Go** – A monitoring system and time series database', priority: 60 }, |
| 25 | + { url: 'https://github.com/nushell/nushell', description: '**Rust** – A terminal emulator written in Rust', priority: 50 }, |
| 26 | + { url: 'https://github.com/gitpod-io/spring-petclinic', description: '**Java** – A Spring sample web application', priority: 40 }, |
| 27 | + { url: 'https://github.com/gitpod-io/ruby-on-rails', description: '**Ruby** – A Rails example with PostgreSQL database', priority: 30 }, |
| 28 | + { url: 'https://github.com/gitpod-io/dotnetcore', description: '**C#** – A simple .NET Core application example', priority: 20 }, |
| 29 | + { url: 'https://github.com/symfony/demo', description: '**PHP** – A Symfony demo application', priority: 10 }, |
| 30 | + ] |
| 31 | + const currentEntries = await queryRunner.query(`SELECT * FROM d_b_repository_white_list ORDER BY priority DESC`); |
| 32 | + if (JSON.stringify(currentEntries, null, 2) === JSON.stringify(oldEntries, null, 2)) { |
| 33 | + await queryRunner.query("DELETE FROM d_b_repository_white_list"); |
| 34 | + await Promise.all(newEntries.map(e => queryRunner.query(`INSERT IGNORE INTO d_b_repository_white_list (url, description, priority) VALUES (?, ?, ?)`, [e.url, e.description, e.priority]))); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + public async down(queryRunner: QueryRunner): Promise<any> { |
| 39 | + } |
| 40 | + |
| 41 | +} |
0 commit comments