typeorm#TableColumn TypeScript Examples

The following examples show how to use typeorm#TableColumn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: 1597868247673-AddWeightsToRole.ts    From radiopanel with GNU General Public License v3.0 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<any> {
		const weight = new TableColumn({
			name: 'weight',
			type: 'integer',
			isPrimary: false,
			isNullable: true,
			default: 0,
		});

		await queryRunner.addColumn('role', weight);
	}
Example #2
Source File: 1586818064869-AddAvatarFieldToUsers.ts    From gobarber-api with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'users',
      new TableColumn({
        name: 'avatar',
        type: 'varchar',
        isNullable: true,
      }),
    );
  }
Example #3
Source File: 1589854644313-AddUserIdToAppointments.ts    From GoBarber with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'appointments',
      new TableColumn({
        name: 'user_id',
        type: 'uuid',
        isNullable: true,
      }),
    );

    await queryRunner.createForeignKey(
      'appointments',
      new TableForeignKey({
        name: 'AppointmentUser',
        columnNames: ['user_id'],
        referencedColumnNames: ['id'],
        referencedTableName: 'users',
        onDelete: 'SET NULL',
        onUpdate: 'CASCADE',
      }),
    );

    // Cascade
  }
Example #4
Source File: 1583435040290-AddStorageToTenant.ts    From radiopanel with GNU General Public License v3.0 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<any> {
		const column = new TableColumn({
			name: 'storage',
			type: 'jsonb',
			isPrimary: false,
			isNullable: true,
		});

		await queryRunner.addColumn('tenant', column);
	}
Example #5
Source File: 1586975069030-AddAvatarFieldToUsers.ts    From GoBarber with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'users',
      new TableColumn({
        name: 'avatar',
        type: 'varchar',
        isNullable: true,
      }),
    );
  }
Example #6
Source File: 1598470382253-AddTenantUuidToUserPermission.ts    From radiopanel with GNU General Public License v3.0 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<any> {
		const permissionType = new TableColumn({
			name: 'permissionType',
			type: 'varchar',
			length: '255',
			isPrimary: false,
			isNullable: false,
		});

		await queryRunner.addColumn('user_permission', permissionType);
	}
Example #7
Source File: 1555504622184-AddColumnInCustomer.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<any> {
        const ifExist = await queryRunner.hasColumn('customer', 'local');
        if (!ifExist) {
            await queryRunner.addColumn('customer', new TableColumn({
                name: 'local',
                type: 'varchar',
                length: '255',
                isPrimary: false,
                isNullable: true,
            }));
        }
        const ifExistColumn = await queryRunner.hasColumn('customer', 'oauth_data');
        if (!ifExistColumn) {
        await queryRunner.addColumn('customer', new TableColumn({
            name: 'oauth_data',
            type: 'varchar',
            length: '255',
            isPrimary: false,
            isNullable: true,
        }));
    }
}
Example #8
Source File: 1593913539547-AddExpiresAtColumn.ts    From hotseat-api with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'recover_password_requests',
      new TableColumn({
        name: 'expires_at',
        type: 'timestamp',
        default: 'now()',
      }),
    );
  }
Example #9
Source File: 1588957767413-AddUserIdToAppointments.ts    From gobarber-api with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'appointments',
      new TableColumn({
        name: 'user_id',
        type: 'uuid',
        isNullable: true,
      }),
    );

    await queryRunner.createForeignKey(
      'appointments',
      new TableForeignKey({
        name: 'AppointmentUser',
        columnNames: ['user_id'],
        referencedTableName: 'users',
        referencedColumnNames: ['id'],
        onDelete: 'SET NULL',
        onUpdate: 'CASCADE',
      }),
    );
  }
Example #10
Source File: 1589537971099-Appointments.ts    From hotseat-api with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumns('appointments', [
      new TableColumn({
        name: 'created_at',
        type: 'date',
        default: 'now()',
      }),
      new TableColumn({
        name: 'updated_at',
        type: 'date',
        default: 'now()',
      }),
    ]);
  }
Example #11
Source File: 1586960843260-AlterProviderFildToProviderId.ts    From GoBarber with MIT License 6 votes vote down vote up
public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropForeignKey('appointments', 'AppointmentProvider');

    await queryRunner.dropColumn('appointments', 'provider_id');

    await queryRunner.addColumn(
      'appointments',
      new TableColumn({
        name: 'provider',
        type: 'uuid',
        isNullable: true,
      }),
    );
  }
Example #12
Source File: 1593959384755-AddTimestampColumnsToRecoverPasswordRequest.ts    From hotseat-api with MIT License 6 votes vote down vote up
public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropColumns('recover_password_requests', [
      new TableColumn({
        name: 'created_at',
        type: 'timestamp',
        default: 'now()',
      }),
      new TableColumn({
        name: 'updated_at',
        type: 'timestamp',
        default: 'now()',
      }),
    ]);
  }
Example #13
Source File: 1586960843260-AlterProviderFildToProviderId.ts    From GoBarber with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropColumn('appointments', 'provider');
    await queryRunner.addColumn(
      'appointments',
      new TableColumn({
        name: 'provider_id',
        type: 'uuid',
        isNullable: true,
      }),
    );

    await queryRunner.createForeignKey(
      'appointments',
      new TableForeignKey({
        name: 'AppointmentProvider',
        columnNames: ['provider_id'],
        referencedColumnNames: ['id'],
        referencedTableName: 'users',
        onDelete: 'SET NULL',
        onUpdate: 'CASCADE',
      }),
    );

    // Cascade
  }
Example #14
Source File: 1607024183135-AddUserIdToAppointments.ts    From gobarber-project with MIT License 6 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'appointments',
      new TableColumn({
        name: 'user_id',
        type: 'uuid',
        isNullable: true,
      }),
    );

    await queryRunner.createForeignKey(
      'appointments',
      new TableForeignKey({
        name: 'AppointmentUser',
        columnNames: ['user_id'],
        referencedColumnNames: ['id'],
        referencedTableName: 'users',
        onDelete: 'SET NULL',
        onUpdate: 'CASCADE',
      }),
    );
  }
Example #15
Source File: 3_ArrangementId.ts    From ADR-Gateway with MIT License 6 votes vote down vote up
Perform = async (connection:Connection) => {
    const runner = connection.createQueryRunner("master");
    const tableName = (connection.options.entityPrefix || "")+'consent_request_log';
    await runner.addColumn(tableName,new TableColumn({
      isNullable:true,
      type:"varchar",
      name:"arrangementId",
      length: "255"
    }))

    const values = {
      id: "3_AddArrangementIdMigration",
      performed: moment().utc().toISOString()
    }
    await connection.createQueryBuilder().insert().into(`${connection.options.entityPrefix || ""}MigrationLog`,["id","performed"]).values(values).execute()
  }
Example #16
Source File: 1594569653170-AddCustomerIdToAppointment.ts    From hotseat-api with MIT License 6 votes vote down vote up
public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropForeignKey('appointments', 'appointment_customer_id');

    await queryRunner.dropColumn(
      'appointments',
      new TableColumn({
        name: 'customer_id',
        type: 'uuid',
        isNullable: true,
      }),
    );
  }
Example #17
Source File: 1634308884591-Stickers.ts    From fosscord-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.dropForeignKey("read_states", "FK_6f255d873cfbfd7a93849b7ff74");
		await queryRunner.changeColumn(
			"stickers",
			"tags",
			new TableColumn({ name: "tags", type: "varchar", isNullable: true })
		);
		await queryRunner.changeColumn(
			"stickers",
			"pack_id",
			new TableColumn({ name: "pack_id", type: "varchar", isNullable: true })
		);
		await queryRunner.changeColumn("stickers", "type", new TableColumn({ name: "type", type: "integer" }));
		await queryRunner.changeColumn(
			"stickers",
			"format_type",
			new TableColumn({ name: "format_type", type: "integer" })
		);
		await queryRunner.changeColumn(
			"stickers",
			"available",
			new TableColumn({ name: "available", type: "boolean", isNullable: true })
		);
		await queryRunner.changeColumn(
			"stickers",
			"user_id",
			new TableColumn({ name: "user_id", type: "boolean", isNullable: true })
		);
		await queryRunner.createForeignKey(
			"stickers",
			new TableForeignKey({
				name: "FK_8f4ee73f2bb2325ff980502e158",
				columnNames: ["user_id"],
				referencedColumnNames: ["id"],
				referencedTableName: "users",
				onDelete: "CASCADE",
			})
		);
		await queryRunner.createTable(
			new Table({
				name: "sticker_packs",
				columns: [
					new TableColumn({ name: "id", type: "varchar", isPrimary: true }),
					new TableColumn({ name: "name", type: "varchar" }),
					new TableColumn({ name: "description", type: "varchar", isNullable: true }),
					new TableColumn({ name: "banner_asset_id", type: "varchar", isNullable: true }),
					new TableColumn({ name: "cover_sticker_id", type: "varchar", isNullable: true }),
				],
				foreignKeys: [
					new TableForeignKey({
						columnNames: ["cover_sticker_id"],
						referencedColumnNames: ["id"],
						referencedTableName: "stickers",
					}),
				],
			})
		);
	}
Example #18
Source File: 1623428655107-AddPublishTimingToEntity.ts    From radiopanel with GNU General Public License v3.0 5 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<any> {
		const published = new TableColumn({
			name: 'published',
			type: 'boolean',
			default: 'true',
			isPrimary: false,
			isNullable: false,
		});

		const publishScheduledAt = new TableColumn({
			name: 'publishScheduledAt',
			type: 'timestamp',
			isPrimary: false,
			isNullable: true,
		});

		const unPublishScheduledAt = new TableColumn({
			name: 'unPublishScheduledAt',
			type: 'timestamp',
			isPrimary: false,
			isNullable: true,
		});

		const publishedAt = new TableColumn({
			name: 'publishedAt',
			type: 'timestamp',
			isPrimary: false,
			isNullable: true,
		});

		await queryRunner.addColumn('content', published);
		await queryRunner.addColumn('page', published);

		await queryRunner.addColumn('content', publishScheduledAt);
		await queryRunner.addColumn('page', publishScheduledAt);

		await queryRunner.addColumn('content', unPublishScheduledAt);
		await queryRunner.addColumn('page', unPublishScheduledAt);

		await queryRunner.addColumn('content', publishedAt);
		await queryRunner.addColumn('page', publishedAt);
	}
Example #19
Source File: 1601408180275-add_opening_hours_field_to_orphanages.ts    From nlw-03-omnistack with MIT License 5 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn('orphanages', new TableColumn({
      name: 'opening_hours',
      type: 'varchar'
    }))
  }
Example #20
Source File: 1634426540271-MigrationTimestamp.ts    From fosscord-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public async up(queryRunner: QueryRunner): Promise<void> {
		await queryRunner.changeColumn(
			"migrations",
			"timestamp",
			new TableColumn({ name: "timestampe", type: "bigint", isNullable: false })
		);
	}