|
1 | | -// import { MigrationInterface, QueryRunner } from 'typeorm'; |
| 1 | +import { MigrationInterface, QueryRunner } from 'typeorm'; |
2 | 2 |
|
3 | | -// export class PointIndex1729964897242 implements MigrationInterface { |
4 | | -// public async up(queryRunner: QueryRunner): Promise<void> { |
5 | | -// // 1. Add the 'location_point' column as NULLABLE |
6 | | -// await queryRunner.query(` |
7 | | -// ALTER TABLE wp_realty_listingsdb |
8 | | -// ADD COLUMN location_point POINT NULL; |
9 | | -// `); |
| 3 | +export class PointIndex1729964897242 implements MigrationInterface { |
| 4 | + public async up(queryRunner: QueryRunner): Promise<void> { |
| 5 | + // 1. Add the 'location_point' column as NULLABLE |
| 6 | + await queryRunner.query(` |
| 7 | + ALTER TABLE wp_realty_listingsdb |
| 8 | + ADD COLUMN location_point POINT NULL; |
| 9 | + `); |
10 | 10 |
|
11 | | -// // 2. Populate the 'location_point' column with existing data |
12 | | -// await queryRunner.query(` |
13 | | -// UPDATE wp_realty_listingsdb |
14 | | -// SET location_point = POINT(longitude, latitude); |
15 | | -// `); |
| 11 | + // 2. Populate the 'location_point' column with existing data |
| 12 | + await queryRunner.query(` |
| 13 | + UPDATE wp_realty_listingsdb |
| 14 | + SET location_point = POINT(longitude, latitude); |
| 15 | + `); |
16 | 16 |
|
17 | | -// // 3. Alter the 'location_point' column to NOT NULL |
18 | | -// await queryRunner.query(` |
19 | | -// ALTER TABLE wp_realty_listingsdb |
20 | | -// MODIFY COLUMN location_point POINT NOT NULL; |
21 | | -// `); |
| 17 | + // 3. Alter the 'location_point' column to NOT NULL |
| 18 | + await queryRunner.query(` |
| 19 | + ALTER TABLE wp_realty_listingsdb |
| 20 | + MODIFY COLUMN location_point POINT NOT NULL; |
| 21 | + `); |
22 | 22 |
|
23 | | -// // 4. Add a spatial index on the 'location_point' column |
24 | | -// await queryRunner.query(` |
25 | | -// ALTER TABLE wp_realty_listingsdb |
26 | | -// ADD SPATIAL INDEX idx_location_point (location_point); |
27 | | -// `); |
28 | | -// } |
| 23 | + // 4. Add a spatial index on the 'location_point' column |
| 24 | + await queryRunner.query(` |
| 25 | + ALTER TABLE wp_realty_listingsdb |
| 26 | + ADD SPATIAL INDEX idx_location_point (location_point); |
| 27 | + `); |
| 28 | + } |
29 | 29 |
|
30 | | -// public async down(queryRunner: QueryRunner): Promise<void> { |
31 | | -// // 1. Drop the spatial index |
32 | | -// await queryRunner.query(` |
33 | | -// ALTER TABLE wp_realty_listingsdb |
34 | | -// DROP INDEX idx_location_point; |
35 | | -// `); |
| 30 | + public async down(queryRunner: QueryRunner): Promise<void> { |
| 31 | + // 1. Drop the spatial index |
| 32 | + await queryRunner.query(` |
| 33 | + ALTER TABLE wp_realty_listingsdb |
| 34 | + DROP INDEX idx_location_point; |
| 35 | + `); |
36 | 36 |
|
37 | | -// // 2. Drop the 'location_point' column |
38 | | -// await queryRunner.query(` |
39 | | -// ALTER TABLE wp_realty_listingsdb |
40 | | -// DROP COLUMN location_point; |
41 | | -// `); |
42 | | -// } |
43 | | -// } |
| 37 | + // 2. Drop the 'location_point' column |
| 38 | + await queryRunner.query(` |
| 39 | + ALTER TABLE wp_realty_listingsdb |
| 40 | + DROP COLUMN location_point; |
| 41 | + `); |
| 42 | + } |
| 43 | +} |
0 commit comments