--- /dev/null
+REQUIRES = mysql helm-metadata
+
+INTERFACE_FILES =
+IMPLEMENTATION_FILES = $(INTERFACE_FILES:%.mli=%.ml)
+EXTRA_OBJECTS_TO_INSTALL =
+EXTRA_OBJECTS_TO_CLEAN =table_creator table_creator.opt
+
+all: table_creator
+opt: table_creator.opt
+
+table_creator: table_creator.ml
+ $(OCAMLFIND) ocamlc \
+ -thread -package mysql,helm-metadata -linkpkg -o $@ $<
+
+table_creator.opt: table_creator.ml
+ $(OCAMLFIND) ocamlopt \
+ -thread -package mysql,helm-metadata -linkpkg -o $@ $<
+
+include ../../Makefile.common
+include .depend
--- /dev/null
+
+let map =
+ (MetadataTypes.library_obj_tbl,`RefObj) ::
+ (MetadataTypes.library_sort_tbl,`RefSort) ::
+ (MetadataTypes.library_rel_tbl,`RefRel) ::
+ (MetadataTypes.library_name_tbl,`ObjectName) ::
+(* (MetadataTypes.library_???_tbl,`Owners) :: *)
+ (MetadataTypes.library_count_tbl,`Count) :: []
+
+let usage argv_o =
+ prerr_string "\nusage:";
+ prerr_string ("\t" ^ argv_o ^ " [-index] tablename[=rename]\n\n");
+ prerr_string "known tables:";
+ List.iter (fun (n,_) -> prerr_string (" " ^ n)) map;
+ prerr_endline "\n"
+
+let eq_RE = Str.regexp "="
+
+let parse_args l =
+ List.map (fun s ->
+ let parts = Str.split eq_RE s in
+ let len = List.length parts in
+ assert (len = 1 || len = 2);
+ if len = 1 then (s,s) else (List.nth parts 0, List.nth parts 1))
+ l
+
+let main () =
+ let len = Array.length Sys.argv in
+ if len < 2 then
+ begin
+ usage Sys.argv.(0);
+ exit 1
+ end
+ else
+ begin
+ let from, index = if Sys.argv.(1) = "-index" then 2,true else 1,false in
+ let todo = Array.to_list (Array.sub Sys.argv from (len - from)) in
+ let todo = parse_args todo in
+ let todo = List.map (fun (x,name) -> name, (List.assoc x map)) todo in
+ print_endline (SqlStatements.create_tables todo);
+ if index then print_endline (SqlStatements.create_indexes todo)
+ end
+
+let _ = main ()
+