 )
 
 
+;;;;;;;;;;;;;;;
+;;
+;; migrations
+
+(defn- migrate__reinit_seats! []
+	(sql/with-db-connection [c CONN] 
+		(sql/delete! c "seats" ["1 = 1"])
+		(apply sql/insert! c "seats" 
+			(gen-seats-data seat-schema))))
+
+(defn- migrate__seats_for_judges! []
+	(create-booking "ЖУРІ" "-" [])
+	)
+
+
+(defn init-db[] 
+	(when-not (migrated? "testing")
+		(create-testing-table!))
+
+	(when-not (migrated? "seats")
+		(create-seats-table!))
+
+	(when-not (migrated? "bookings")
+		(create-bookings-table!))
+
+	(when-not (migrated? "history")
+		(create-history-table!))
+	
+	;(try
+	;	...
+	;	(catch Exception e 
+	;		(do 
+	;			(print (.getNextException e)))))
+
+	(migrate-live! "1_reinit_seats" migrate__reinit_seats!)
+
+	;(migrate-live! "2_seats_for_judges"  migrate__seats_for_judges!)
+
+)
 
 
 
+
+
+
+
+
+
+
+

		(apply sql/insert! c "seats" 
			(gen-seats-data seat-schema))))

(defn create-bookings-table [] 
	(sql/with-db-connection [c CONN] 
		(sql/db-do-commands c
	                    (sql/create-table-ddl "bookings"

	                     (sql/drop-table-ddl table))))


(defn create-testing-table! []
	(sql/db-do-commands CONN
	                    (sql/create-table-ddl :testing [:data :text]))
		(sql/insert! CONN
