Browse Source

fix: add upgrader to update env

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/653/head
Pranav C 3 years ago
parent
commit
3062e25f9e
  1. 36
      .github/workflows/ci-cd.yml
  2. 2
      packages/nocodb/src/lib/noco/Noco.ts
  3. 4
      packages/nocodb/src/lib/noco/upgrader/NcUpgrader.ts
  4. 11
      packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectEnvUpgrader0011045.ts

36
.github/workflows/ci-cd.yml

@ -9,24 +9,24 @@ on:
branches: [ master ] branches: [ master ]
jobs: jobs:
cypress-run: # cypress-run:
runs-on: ubuntu-20.04 # runs-on: ubuntu-20.04
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v2 # uses: actions/checkout@v2
with: # with:
fetch-depth: 0 # fetch-depth: 0
- name: Check for update # - name: Check for update
run: | # run: |
echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nc-gui) = nc-gui ]] && echo 'OK')" >> $GITHUB_ENV # echo "CHANGED=$([[ $(lerna ls --since ${{github.event.before}} | grep nc-gui) = nc-gui ]] && echo 'OK')" >> $GITHUB_ENV
#
- name: Cypress run # - name: Cypress run
if: ${{ env.CHANGED == 'OK' }} # if: ${{ env.CHANGED == 'OK' }}
uses: cypress-io/github-action@v2 # uses: cypress-io/github-action@v2
with: # with:
start: docker-compose -f ./docker-compose-cypress.yml up -d # start: docker-compose -f ./docker-compose-cypress.yml up -d
wait-on: 'http://localhost:3000' # wait-on: 'http://localhost:3000'
wait-on-timeout: 900 # wait-on-timeout: 900
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

2
packages/nocodb/src/lib/noco/Noco.ts

@ -90,7 +90,7 @@ export default class Noco {
constructor() { constructor() {
process.env.PORT = process.env.PORT || '8080'; process.env.PORT = process.env.PORT || '8080';
// todo: move // todo: move
process.env.NC_VERSION = '0011043'; process.env.NC_VERSION = '0011045';
this.router = express.Router(); this.router = express.Router();
this.projectRouter = express.Router(); this.projectRouter = express.Router();

4
packages/nocodb/src/lib/noco/upgrader/NcUpgrader.ts

@ -3,6 +3,7 @@ import { NcConfig } from '../../../interface/config';
import debug from 'debug'; import debug from 'debug';
import NcMetaIO from '../meta/NcMetaIO'; import NcMetaIO from '../meta/NcMetaIO';
import ncProjectEnvUpgrader from './jobs/ncProjectEnvUpgrader'; import ncProjectEnvUpgrader from './jobs/ncProjectEnvUpgrader';
import ncProjectEnvUpgrader0011045 from './jobs/ncProjectEnvUpgrader0011045';
const log = debug('nc:upgrader'); const log = debug('nc:upgrader');
@ -23,7 +24,8 @@ export default class NcUpgrader {
const NC_VERSIONS: any[] = [ const NC_VERSIONS: any[] = [
{ name: '0009000', handler: null }, { name: '0009000', handler: null },
{ name: '0009044', handler: null }, { name: '0009044', handler: null },
{ name: '0011043', handler: ncProjectEnvUpgrader } { name: '0011043', handler: ncProjectEnvUpgrader },
{ name: '0011045', handler: ncProjectEnvUpgrader0011045 }
]; ];
if (!(await ctx.ncMeta.knexConnection?.schema?.hasTable?.('nc_store'))) { if (!(await ctx.ncMeta.knexConnection?.schema?.hasTable?.('nc_store'))) {
return; return;

11
packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectEnvUpgrader0011045.ts

@ -0,0 +1,11 @@
import { NcUpgraderCtx } from '../NcUpgrader';
export default async function(ctx: NcUpgraderCtx) {
const projects = await ctx.ncMeta.projectList();
for (const project of projects) {
const projectConfig = JSON.parse(project.config);
projectConfig.env = '_noco';
await ctx.ncMeta.projectUpdate(project?.id, projectConfig);
}
}
Loading…
Cancel
Save