oops, for customer categories
[freeside.git] / FS / bin / freeside-dbdef-create
1 #!/usr/bin/perl -Tw
2
3 use strict;
4 use DBI;
5 use DBIx::DBSchema 0.26;
6 use FS::UID qw(adminsuidsetup datasrc driver_name);
7 use FS::Schema;
8
9 my $user = shift or die &usage;
10
11 $FS::Schema::setup_hack = 1;
12 $FS::CurrentUser::upgrade_hack = 1;
13 my($dbh)=adminsuidsetup $user;
14
15 #needs to match FS::Record
16 my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
17
18 my $dbdef = new_native DBIx::DBSchema $dbh;
19
20 #print $dbdef->pretty_print;
21
22 #important
23 $dbdef->save($dbdef_file);
24
25 sub usage {
26   die "Usage:\n  dbdef-create user\n";
27 }
28
29 =head1 NAME
30
31 freeside-dbdef-create - Recreate database schema cache
32
33 =head1 SYNOPSIS
34
35   freeside-dbdef-create user
36
37 =head1 DESCRIPTION
38
39 Reverse engineers the database schema and recreates the dbdef cache file.
40
41 =head1 SEE ALSO
42
43 L<DBIx::DBSchema>
44
45 =cut
46
47 1;