Compare commits

...

11 Commits

Author SHA1 Message Date
Aswin V 46a6ba4f54
Merge 5e21208b77 into 5000983a36 2024-05-02 01:21:31 +00:00
Deepak Prabhakara 5e21208b77 fixed indexNamespace 2024-05-02 02:21:22 +01:00
Deepak Prabhakara b543987832 Merge branch 'release' into db-expand-namespace-col 2024-05-01 23:35:58 +01:00
Aswin V 7610ce7e9b
Merge branch 'main' into db-expand-namespace-col 2024-04-30 14:51:17 +05:30
Aswin V 9b0510a885 Planetscale migration 2024-04-30 11:56:50 +05:30
Aswin V cb5e443356 Postgres migration 2024-04-30 10:36:36 +05:30
Aswin V f9b21a56c4 MSSQL migration 2024-04-30 02:10:04 +05:30
Aswin V e846774bea MySQL migration 2024-04-30 01:14:19 +05:30
Aswin V 8ac30e6be7 MariaDB migration 2024-04-30 00:50:18 +05:30
Aswin V 51f0b43084 Merge branch 'main' into db-expand-namespace-col 2024-04-30 00:10:47 +05:30
Aswin V 2f8ae15eb5 Increase size of namespace column 2024-04-29 23:55:44 +05:30
10 changed files with 89 additions and 16 deletions

View File

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class MdNamespace1714417013715 implements MigrationInterface {
name = 'MdNamespace1714417013715'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(256) NULL`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(64) NULL`);
}
}

View File

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class MssNamespace1714421718208 implements MigrationInterface {
name = 'MssNamespace1714421718208'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "jackson_store" ALTER COLUMN "namespace" varchar(256)`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "jackson_store" ALTER COLUMN "namespace" varchar(64)`);
}
}

View File

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class MsNamespace1714419315556 implements MigrationInterface {
name = 'MsNamespace1714419315556'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(256) NULL`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(64) NULL`);
}
}

View File

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class MsNamespace1714457285484 implements MigrationInterface {
name = 'MsNamespace1714457285484'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(256) NULL`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`jackson_store\` MODIFY \`namespace\` varchar(64) NULL`);
}
}

View File

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class PgNamespace1714452929542 implements MigrationInterface {
name = 'PgNamespace1714452929542'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "jackson_store" ALTER COLUMN "namespace" TYPE VARCHAR(256)`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "jackson_store" ALTER COLUMN "namespace" TYPE VARCHAR(64)`);
}
}

View File

@ -46,7 +46,7 @@ export class JacksonStore {
@Index('_jackson_store_namespace')
@Column({
type: 'varchar',
length: 64,
length: 256,
nullable: true,
})
namespace?: string;

View File

@ -44,7 +44,7 @@ export class JacksonStore {
@Index('_jackson_store_namespace')
@Column({
type: 'varchar',
length: 64,
length: 256,
nullable: true,
})
namespace?: string;

View File

@ -46,7 +46,7 @@ export class JacksonStore {
@Index('_jackson_store_namespace')
@Column({
type: 'varchar',
length: 64,
length: 256,
nullable: true,
})
namespace?: string;

View File

@ -44,7 +44,7 @@ export class JacksonStore {
@Index('_jackson_store_namespace')
@Column({
type: 'varchar',
length: 64,
length: 256,
nullable: true,
})
namespace?: string;

View File

@ -131,19 +131,22 @@ class Sql implements DatabaseDriver {
}
async indexNamespace() {
const res = await this.storeRepository.find({
where: {
namespace: IsNull(),
},
select: ['key'],
});
const searchTerm = ':';
try {
const res = await this.storeRepository.find({
where: {
namespace: IsNull(),
},
select: ['key'],
});
const searchTerm = ':';
for (const r of res) {
const key = r.key;
const tokens2 = key.split(searchTerm).slice(0, 2);
const value = tokens2.join(searchTerm);
await this.storeRepository.update({ key }, { namespace: value });
for (const r of res) {
const key = r.key;
const lastIndex = r.key.lastIndexOf(searchTerm);
await this.storeRepository.update({ key }, { namespace: r.key.substring(0, lastIndex) });
}
} catch (err) {
console.error('Error running indexNamespace:', err);
}
}