summaryrefslogtreecommitdiff
path: root/src/db/Db.c
blob: cafe2e449a720881f510a658a88f0d0a3d3017d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
/* Db.c generated by valac 0.40.4, the Vala compiler
 * generated from Db.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>

#define _g_free0(var) (var = (g_free (var), NULL))

#define DB_TYPE_VERIFY_RESULT (db_verify_result_get_type ())

#define TYPE_DATABASE_TABLE (database_table_get_type ())
#define DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATABASE_TABLE, DatabaseTable))
#define DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATABASE_TABLE, DatabaseTableClass))
#define IS_DATABASE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATABASE_TABLE))
#define IS_DATABASE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATABASE_TABLE))
#define DATABASE_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATABASE_TABLE, DatabaseTableClass))

typedef struct _DatabaseTable DatabaseTable;
typedef struct _DatabaseTableClass DatabaseTableClass;

#define TYPE_VERSION_TABLE (version_table_get_type ())
#define VERSION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VERSION_TABLE, VersionTable))
#define VERSION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VERSION_TABLE, VersionTableClass))
#define IS_VERSION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VERSION_TABLE))
#define IS_VERSION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VERSION_TABLE))
#define VERSION_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VERSION_TABLE, VersionTableClass))

typedef struct _VersionTable VersionTable;
typedef struct _VersionTableClass VersionTableClass;
#define _database_table_unref0(var) ((var == NULL) ? NULL : (var = (database_table_unref (var), NULL)))

#define TYPE_APPLICATION (application_get_type ())
#define APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APPLICATION, Application))
#define APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APPLICATION, ApplicationClass))
#define IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APPLICATION))
#define IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APPLICATION))
#define APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APPLICATION, ApplicationClass))

typedef struct _Application Application;
typedef struct _ApplicationClass ApplicationClass;
#define _application_unref0(var) ((var == NULL) ? NULL : (var = (application_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

typedef enum  {
	DB_VERIFY_RESULT_OK,
	DB_VERIFY_RESULT_FUTURE_VERSION,
	DB_VERIFY_RESULT_UPGRADE_ERROR,
	DB_VERIFY_RESULT_NO_UPGRADE_AVAILABLE
} DbVerifyResult;


extern gchar* db_filename;
gchar* db_filename = NULL;

#define DB_IN_MEMORY_NAME ":memory:"
void db_preconfigure (GFile* db_file);
void db_init (GError** error);
void database_table_init (const gchar* filename);
void db_terminate (void);
void database_table_terminate (void);
GType db_verify_result_get_type (void) G_GNUC_CONST;
DbVerifyResult db_verify_database (gchar* * app_version,
                                   gint* schema_version);
gpointer database_table_ref (gpointer instance);
void database_table_unref (gpointer instance);
GParamSpec* param_spec_database_table (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
void value_set_database_table (GValue* value,
                               gpointer v_object);
void value_take_database_table (GValue* value,
                                gpointer v_object);
gpointer value_get_database_table (const GValue* value);
GType database_table_get_type (void) G_GNUC_CONST;
GType version_table_get_type (void) G_GNUC_CONST;
VersionTable* version_table_get_instance (void);
gint version_table_get_version (VersionTable* self,
                                gchar* * app_version);
#define DATABASE_TABLE_SCHEMA_VERSION 20
#define RESOURCES_APP_VERSION _VERSION
void version_table_set_version (VersionTable* self,
                                gint version,
                                const gchar* app_version,
                                const gchar* user_data);
DbVerifyResult db_upgrade_database (gint input_version);
gboolean database_table_has_column (const gchar* table_name,
                                    const gchar* column_name);
gboolean database_table_add_column (const gchar* table_name,
                                    const gchar* column_name,
                                    const gchar* column_constraints);
gboolean database_table_has_table (const gchar* table_name);
gboolean database_table_ensure_column (const gchar* table_name,
                                       const gchar* column_name,
                                       const gchar* column_constraints,
                                       const gchar* upgrade_msg);
void tag_table_upgrade_for_htags (void);
void gsettings_configuration_engine_run_gsettings_migrator (void);
gpointer application_ref (gpointer instance);
void application_unref (gpointer instance);
GParamSpec* param_spec_application (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags);
void value_set_application (GValue* value,
                            gpointer v_object);
void value_take_application (GValue* value,
                             gpointer v_object);
gpointer value_get_application (const GValue* value);
GType application_get_type (void) G_GNUC_CONST;
Application* application_get_instance (void);
void application_set_raw_thumbs_fix_required (Application* self,
                                              gboolean should_fixup);
void version_table_update_version (VersionTable* self,
                                   gint version,
                                   const gchar* app_version);


void
db_preconfigure (GFile* db_file)
{
	gchar* _tmp0_ = NULL;
	gchar* _tmp3_;
#line 14 "/home/jens/Source/shotwell/src/db/Db.vala"
	g_return_if_fail ((db_file == NULL) || G_IS_FILE (db_file));
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (db_file != NULL) {
#line 144 "Db.c"
		gchar* _tmp1_;
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp1_ = g_file_get_path (db_file);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_g_free0 (_tmp0_);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp0_ = _tmp1_;
#line 152 "Db.c"
	} else {
		gchar* _tmp2_;
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp2_ = g_strdup (DB_IN_MEMORY_NAME);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_g_free0 (_tmp0_);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp0_ = _tmp2_;
#line 161 "Db.c"
	}
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp3_ = g_strdup (_tmp0_);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
	_g_free0 (db_filename);
#line 15 "/home/jens/Source/shotwell/src/db/Db.vala"
	db_filename = _tmp3_;
#line 14 "/home/jens/Source/shotwell/src/db/Db.vala"
	_g_free0 (_tmp0_);
#line 171 "Db.c"
}


void
db_init (GError** error)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
#line 19 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp0_ = db_filename;
#line 19 "/home/jens/Source/shotwell/src/db/Db.vala"
	_vala_assert (_tmp0_ != NULL, "filename != null");
#line 21 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp1_ = db_filename;
#line 21 "/home/jens/Source/shotwell/src/db/Db.vala"
	database_table_init (_tmp1_);
#line 188 "Db.c"
}


void
db_terminate (void)
{
#line 25 "/home/jens/Source/shotwell/src/db/Db.vala"
	database_table_terminate ();
#line 197 "Db.c"
}


GType
db_verify_result_get_type (void)
{
	static volatile gsize db_verify_result_type_id__volatile = 0;
	if (g_once_init_enter (&db_verify_result_type_id__volatile)) {
		static const GEnumValue values[] = {{DB_VERIFY_RESULT_OK, "DB_VERIFY_RESULT_OK", "ok"}, {DB_VERIFY_RESULT_FUTURE_VERSION, "DB_VERIFY_RESULT_FUTURE_VERSION", "future-version"}, {DB_VERIFY_RESULT_UPGRADE_ERROR, "DB_VERIFY_RESULT_UPGRADE_ERROR", "upgrade-error"}, {DB_VERIFY_RESULT_NO_UPGRADE_AVAILABLE, "DB_VERIFY_RESULT_NO_UPGRADE_AVAILABLE", "no-upgrade-available"}, {0, NULL, NULL}};
		GType db_verify_result_type_id;
		db_verify_result_type_id = g_enum_register_static ("DbVerifyResult", values);
		g_once_init_leave (&db_verify_result_type_id__volatile, db_verify_result_type_id);
	}
	return db_verify_result_type_id__volatile;
}


DbVerifyResult
db_verify_database (gchar* * app_version,
                    gint* schema_version)
{
	gchar* _vala_app_version = NULL;
	gint _vala_schema_version = 0;
	DbVerifyResult result = 0;
	VersionTable* version_table = NULL;
	VersionTable* _tmp0_;
	VersionTable* _tmp1_;
	gchar* _tmp2_ = NULL;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp7_;
#line 36 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp0_ = version_table_get_instance ();
#line 36 "/home/jens/Source/shotwell/src/db/Db.vala"
	version_table = _tmp0_;
#line 37 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp1_ = version_table;
#line 37 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp3_ = version_table_get_version (_tmp1_, &_tmp2_);
#line 37 "/home/jens/Source/shotwell/src/db/Db.vala"
	_g_free0 (_vala_app_version);
#line 37 "/home/jens/Source/shotwell/src/db/Db.vala"
	_vala_app_version = _tmp2_;
#line 37 "/home/jens/Source/shotwell/src/db/Db.vala"
	_vala_schema_version = _tmp3_;
#line 39 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp4_ = _vala_schema_version;
#line 39 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (_tmp4_ >= 0) {
#line 247 "Db.c"
		gint _tmp5_;
		const gchar* _tmp6_;
#line 40 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp5_ = _vala_schema_version;
#line 40 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp6_ = _vala_app_version;
#line 40 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_debug ("Db.vala:40: Database schema version %d created by app version %s", _tmp5_, _tmp6_);
#line 256 "Db.c"
	}
#line 42 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp7_ = _vala_schema_version;
#line 42 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (_tmp7_ == -1) {
#line 262 "Db.c"
		VersionTable* _tmp8_;
		gchar* _tmp9_;
#line 44 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_debug ("Db.vala:44: Creating database schema version %d for app version %s", DATABASE_TABLE_SCHEMA_VERSION, RESOURCES_APP_VERSION);
#line 46 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp8_ = version_table;
#line 46 "/home/jens/Source/shotwell/src/db/Db.vala"
		version_table_set_version (_tmp8_, DATABASE_TABLE_SCHEMA_VERSION, RESOURCES_APP_VERSION, NULL);
#line 47 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp9_ = g_strdup (RESOURCES_APP_VERSION);
#line 47 "/home/jens/Source/shotwell/src/db/Db.vala"
		_g_free0 (_vala_app_version);
#line 47 "/home/jens/Source/shotwell/src/db/Db.vala"
		_vala_app_version = _tmp9_;
#line 48 "/home/jens/Source/shotwell/src/db/Db.vala"
		_vala_schema_version = DATABASE_TABLE_SCHEMA_VERSION;
#line 279 "Db.c"
	} else {
		gint _tmp10_;
#line 49 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp10_ = _vala_schema_version;
#line 49 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (_tmp10_ > DATABASE_TABLE_SCHEMA_VERSION) {
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_FUTURE_VERSION;
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
			_database_table_unref0 (version_table);
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
			if (app_version) {
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
				*app_version = _vala_app_version;
#line 294 "Db.c"
			} else {
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
				_g_free0 (_vala_app_version);
#line 298 "Db.c"
			}
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
			if (schema_version) {
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
				*schema_version = _vala_schema_version;
#line 304 "Db.c"
			}
#line 51 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 308 "Db.c"
		} else {
			gint _tmp11_;
#line 52 "/home/jens/Source/shotwell/src/db/Db.vala"
			_tmp11_ = _vala_schema_version;
#line 52 "/home/jens/Source/shotwell/src/db/Db.vala"
			if (_tmp11_ < DATABASE_TABLE_SCHEMA_VERSION) {
#line 315 "Db.c"
				DbVerifyResult _result_ = 0;
				gint _tmp12_;
				DbVerifyResult _tmp13_;
#line 54 "/home/jens/Source/shotwell/src/db/Db.vala"
				_tmp12_ = _vala_schema_version;
#line 54 "/home/jens/Source/shotwell/src/db/Db.vala"
				_result_ = db_upgrade_database (_tmp12_);
#line 55 "/home/jens/Source/shotwell/src/db/Db.vala"
				_tmp13_ = _result_;
#line 55 "/home/jens/Source/shotwell/src/db/Db.vala"
				if (_tmp13_ != DB_VERIFY_RESULT_OK) {
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
					result = _result_;
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
					_database_table_unref0 (version_table);
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
					if (app_version) {
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
						*app_version = _vala_app_version;
#line 335 "Db.c"
					} else {
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
						_g_free0 (_vala_app_version);
#line 339 "Db.c"
					}
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
					if (schema_version) {
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
						*schema_version = _vala_schema_version;
#line 345 "Db.c"
					}
#line 56 "/home/jens/Source/shotwell/src/db/Db.vala"
					return result;
#line 349 "Db.c"
				}
			}
		}
	}
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
	result = DB_VERIFY_RESULT_OK;
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
	_database_table_unref0 (version_table);
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (app_version) {
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
		*app_version = _vala_app_version;
#line 362 "Db.c"
	} else {
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
		_g_free0 (_vala_app_version);
#line 366 "Db.c"
	}
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (schema_version) {
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
		*schema_version = _vala_schema_version;
#line 372 "Db.c"
	}
#line 59 "/home/jens/Source/shotwell/src/db/Db.vala"
	return result;
#line 376 "Db.c"
}


DbVerifyResult
db_upgrade_database (gint input_version)
{
	DbVerifyResult result = 0;
	gint version = 0;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gint _tmp5_;
	VersionTable* _tmp6_;
	VersionTable* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
#line 63 "/home/jens/Source/shotwell/src/db/Db.vala"
	_vala_assert (input_version < DATABASE_TABLE_SCHEMA_VERSION, "input_version < DatabaseTable.SCHEMA_VERSION");
#line 65 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = input_version;
#line 68 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp0_ = version;
#line 68 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (_tmp0_ == 1) {
#line 69 "/home/jens/Source/shotwell/src/db/Db.vala"
		result = DB_VERIFY_RESULT_NO_UPGRADE_AVAILABLE;
#line 69 "/home/jens/Source/shotwell/src/db/Db.vala"
		return result;
#line 405 "Db.c"
	}
#line 71 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp1_ = version;
#line 71 "/home/jens/Source/shotwell/src/db/Db.vala"
	g_message ("Db.vala:71: Upgrading database from schema version %d to %d", _tmp1_, DATABASE_TABLE_SCHEMA_VERSION);
#line 83 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "flags")) {
#line 84 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:84: upgrade_database: adding flags column to PhotoTable");
#line 85 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "flags", "INTEGER DEFAULT 0")) {
#line 86 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 86 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 421 "Db.c"
		}
	}
#line 89 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 3;
#line 100 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "file_format")) {
#line 101 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:101: upgrade_database: adding file_format column to PhotoTable");
#line 102 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "file_format", "INTEGER DEFAULT 0")) {
#line 103 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 103 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 436 "Db.c"
		}
	}
#line 106 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 4;
#line 113 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "title")) {
#line 114 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:114: upgrade_database: adding title column to PhotoTable");
#line 115 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "title", "TEXT")) {
#line 116 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 116 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 451 "Db.c"
		}
	}
#line 119 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 5;
#line 126 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "backlinks")) {
#line 127 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:127: upgrade_database: adding backlinks column to PhotoTable");
#line 128 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "backlinks", "TEXT")) {
#line 129 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 129 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 466 "Db.c"
		}
	}
#line 132 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 6;
#line 146 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "time_reimported")) {
#line 147 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:147: upgrade_database: adding time_reimported column to PhotoT" \
"able");
#line 148 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "time_reimported", "INTEGER")) {
#line 149 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 149 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 481 "Db.c"
		}
	}
#line 152 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "editable_id")) {
#line 153 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:153: upgrade_database: adding editable_id column to PhotoTable");
#line 154 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "editable_id", "INTEGER DEFAULT -1")) {
#line 155 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 155 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 494 "Db.c"
		}
	}
#line 158 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 7;
#line 170 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "rating")) {
#line 171 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:171: upgrade_database: adding rating column to PhotoTable");
#line 172 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "rating", "INTEGER DEFAULT 0")) {
#line 173 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 173 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 509 "Db.c"
		}
	}
#line 182 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "metadata_dirty")) {
#line 183 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:183: upgrade_database: adding metadata_dirty column to PhotoTa" \
"ble");
#line 184 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "metadata_dirty", "INTEGER DEFAULT 1")) {
#line 185 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 185 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 522 "Db.c"
		}
	}
#line 188 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 9;
#line 195 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (database_table_has_table ("VideoTable")) {
#line 195 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp2_ = !database_table_has_column ("VideoTable", "flags");
#line 531 "Db.c"
	} else {
#line 195 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp2_ = FALSE;
#line 535 "Db.c"
	}
#line 195 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (_tmp2_) {
#line 196 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:196: upgrade_database: adding flags column to VideoTable");
#line 197 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("VideoTable", "flags", "INTEGER DEFAULT 0")) {
#line 198 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 198 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 547 "Db.c"
		}
	}
#line 201 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 10;
#line 208 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("EventTable", "primary_source_id")) {
#line 209 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:209: upgrade_database: adding primary_source_id column to Even" \
"tTable");
#line 210 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("EventTable", "primary_source_id", "TEXT")) {
#line 211 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 211 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 562 "Db.c"
		}
	}
#line 214 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 11;
#line 221 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_ensure_column ("TombstoneTable", "reason", "INTEGER DEFAULT 0", "upgrade_database: adding reason column to TombstoneTable")) {
#line 223 "/home/jens/Source/shotwell/src/db/Db.vala"
		result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 223 "/home/jens/Source/shotwell/src/db/Db.vala"
		return result;
#line 573 "Db.c"
	}
#line 226 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 12;
#line 233 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "developer")) {
#line 234 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:234: upgrade_database: adding developer column to PhotoTable");
#line 235 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "developer", "TEXT")) {
#line 236 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 236 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 587 "Db.c"
		}
	}
#line 239 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "develop_shotwell_id")) {
#line 240 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:240: upgrade_database: adding develop_shotwell_id column to Ph" \
"otoTable");
#line 241 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "develop_shotwell_id", "INTEGER DEFAULT -1")) {
#line 242 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 242 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 600 "Db.c"
		}
	}
#line 245 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "develop_camera_id")) {
#line 246 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:246: upgrade_database: adding develop_camera_id column to Phot" \
"oTable");
#line 247 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "develop_camera_id", "INTEGER DEFAULT -1")) {
#line 248 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 248 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 613 "Db.c"
		}
	}
#line 251 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "develop_embedded_id")) {
#line 252 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:252: upgrade_database: adding develop_embedded_id column to Ph" \
"otoTable");
#line 253 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "develop_embedded_id", "INTEGER DEFAULT -1")) {
#line 254 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 254 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 626 "Db.c"
		}
	}
#line 257 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 13;
#line 264 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (input_version < 14) {
#line 265 "/home/jens/Source/shotwell/src/db/Db.vala"
		tag_table_upgrade_for_htags ();
#line 635 "Db.c"
	}
#line 267 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 14;
#line 279 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 15;
#line 289 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (input_version < 16) {
#line 292 "/home/jens/Source/shotwell/src/db/Db.vala"
		gsettings_configuration_engine_run_gsettings_migrator ();
#line 645 "Db.c"
	}
#line 295 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 16;
#line 302 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("PhotoTable", "comment")) {
#line 303 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:303: upgrade_database: adding comment column to PhotoTable");
#line 304 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("PhotoTable", "comment", "TEXT")) {
#line 305 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 305 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 659 "Db.c"
		}
	}
#line 307 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (database_table_has_table ("VideoTable") & (!database_table_has_column ("VideoTable", "comment"))) {
#line 308 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:308: upgrade_database: adding comment column to VideoTable");
#line 309 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("VideoTable", "comment", "TEXT")) {
#line 310 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 310 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 672 "Db.c"
		}
	}
#line 313 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 17;
#line 320 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (!database_table_has_column ("EventTable", "comment")) {
#line 321 "/home/jens/Source/shotwell/src/db/Db.vala"
		g_message ("Db.vala:321: upgrade_database: adding comment column to EventTable");
#line 322 "/home/jens/Source/shotwell/src/db/Db.vala"
		if (!database_table_add_column ("EventTable", "comment", "TEXT")) {
#line 323 "/home/jens/Source/shotwell/src/db/Db.vala"
			result = DB_VERIFY_RESULT_UPGRADE_ERROR;
#line 323 "/home/jens/Source/shotwell/src/db/Db.vala"
			return result;
#line 687 "Db.c"
		}
	}
#line 326 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 18;
#line 337 "/home/jens/Source/shotwell/src/db/Db.vala"
	if (input_version < 19) {
#line 694 "Db.c"
		Application* _tmp3_;
		Application* _tmp4_;
#line 338 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp3_ = application_get_instance ();
#line 338 "/home/jens/Source/shotwell/src/db/Db.vala"
		_tmp4_ = _tmp3_;
#line 338 "/home/jens/Source/shotwell/src/db/Db.vala"
		application_set_raw_thumbs_fix_required (_tmp4_, TRUE);
#line 338 "/home/jens/Source/shotwell/src/db/Db.vala"
		_application_unref0 (_tmp4_);
#line 705 "Db.c"
	}
#line 341 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 19;
#line 351 "/home/jens/Source/shotwell/src/db/Db.vala"
	version = 20;
#line 357 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp5_ = version;
#line 357 "/home/jens/Source/shotwell/src/db/Db.vala"
	_vala_assert (_tmp5_ == DATABASE_TABLE_SCHEMA_VERSION, "version == DatabaseTable.SCHEMA_VERSION");
#line 358 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp6_ = version_table_get_instance ();
#line 358 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp7_ = _tmp6_;
#line 358 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp8_ = version;
#line 358 "/home/jens/Source/shotwell/src/db/Db.vala"
	version_table_update_version (_tmp7_, _tmp8_, RESOURCES_APP_VERSION);
#line 358 "/home/jens/Source/shotwell/src/db/Db.vala"
	_database_table_unref0 (_tmp7_);
#line 360 "/home/jens/Source/shotwell/src/db/Db.vala"
	_tmp9_ = version;
#line 360 "/home/jens/Source/shotwell/src/db/Db.vala"
	g_message ("Db.vala:360: Database upgrade to schema version %d successful", _tmp9_);
#line 362 "/home/jens/Source/shotwell/src/db/Db.vala"
	result = DB_VERIFY_RESULT_OK;
#line 362 "/home/jens/Source/shotwell/src/db/Db.vala"
	return result;
#line 733 "Db.c"
}