name TEXT NOT NULL,
position INTEGER NOT NULL
);
- # Optional: group_id INTEGER NOT NULL
- Optionally, add one or more columns to specify groupings, allowing you
- to maintain independent ordered lists within one table:
-
- CREATE TABLE items (
- item_id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
- position INTEGER NOT NULL,
- group_id INTEGER NOT NULL
- );
-
- Or even
-
- CREATE TABLE items (
- item_id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
- position INTEGER NOT NULL,
- group_id INTEGER NOT NULL,
- other_group_id INTEGER NOT NULL
- );
-
- In your Schema or DB class add Ordered to the top
+ In your Schema or DB class add "Ordered" to the top
of the component list.
__PACKAGE__->load_components(qw( Ordered ... ));
package My::Item;
__PACKAGE__->position_column('position');
- __PACKAGE__->grouping_column('group_id'); # optional
- If you are using one grouping column, specify it as follows:
-
- __PACKAGE__->grouping_column('group_id');
-
- Or if you have multiple grouping columns:
-
- __PACKAGE__->grouping_column(['group_id', 'other_group_id']);
-
- Thats it, now you can change the position of your objects.
+ That's it, now you can change the position of your objects.
#!/use/bin/perl
use My::Item;
=cut
sub ddl_filename {
- my ($self, $type, $dir, $version) = @_;
+ my ($self, $type, $dir, $version, $pversion) = @_;
my $filename = ref($self);
- $filename =~ s/::/-/;
+ $filename =~ s/::/-/g;
- $filename = "$dir$filename-$version-$type.sql";
+ $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql");
+ $filename =~ s/$version/$pversion-$version/ if($pversion);
return $filename;
}