File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ import { type Knex } from 'knex' ;
2+
3+ export async function up ( knex : Knex ) : Promise < void > {
4+ const tableExists = await knex . schema . hasTable ( 'dbo.Photo' ) ;
5+
6+ if ( ! tableExists ) {
7+ // Best guess based on existing code as I don't have a copy of the database
8+ await knex . schema . withSchema ( 'dbo' ) . createTable ( 'Photo' , ( table ) => {
9+ table . increments ( 'RowId' ) . primary ( ) ;
10+ table . integer ( 'CommunityId' ) . nullable ( ) ;
11+ table . integer ( 'PlaceId' ) . nullable ( ) ;
12+ table . binary ( 'File' ) . nullable ( ) ;
13+ table . binary ( 'ThumbFile' ) . nullable ( ) ;
14+ table . string ( 'FeatureName' ) . nullable ( ) ;
15+ table . string ( 'OriginalFileName' ) . nullable ( ) ;
16+ table . string ( 'Address' ) . nullable ( ) ;
17+ table . string ( 'Caption' ) . nullable ( ) ;
18+
19+ table . foreign ( 'CommunityId' ) . references ( 'Community.Id' ) ;
20+ table . foreign ( 'PlaceId' ) . references ( 'Place.Id' ) ;
21+ } ) ;
22+ }
23+ }
24+
25+ export async function down ( knex : Knex ) : Promise < void > {
26+ await knex . schema . withSchema ( 'dbo' ) . dropTableIfExists ( 'Photo' ) ;
27+ }
You can’t perform that action at this time.
0 commit comments