Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Adding Indexes To MySQL Database Tables in DBIC "result source" or "table classes"

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


cochranb at speakeasy

May 12, 2008, 10:36 AM

Post #1 of 2 (199 views)
Permalink
Adding Indexes To MySQL Database Tables in DBIC "result source" or "table classes"

I have a MySQL version 5 table named languagelist structured like this:

create table languagelist
(
lsigntypid varchar(260) NOT NULL,
lstage varchar(260) NULL,
lopcl varchar(260) NULL,
lentdes varchar(260) NULL,
lmajcat varchar(260) NULL,
lfld varchar(260) NULL,
lflsuh varchar(260) NULL,
lflv varchar(260) NULL,
lflvd varchar(260) NULL,
lmemo1 text NULL,
lremarks1 varchar(260) NULL,
lremarks2 varchar(260) NULL,
INDEX (lsigntypid)
) ENGINE = InnoDB;

I (just now) created a DBIC "result source" or "table class" file for
this, following the tutorial at
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7000/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod#Create_the_DBIC_%22Result_Source%22_Files
:

------------(start of table class code)-----------

package SignTypDB::LanguageList;

use base qw/DBIx::Class/;

# Load required DBIC stuff
__PACKAGE__->load_components(qw/PK::Auto Core/);
# Set the table name
__PACKAGE__->table('languagelist');
# Set columns in table
__PACKAGE__->add_columns(qw/lsigntypid lstage lopcl lentdes lmajcat lfld
lflsuh lflv lflvd lmemo1 lremarks1 lremarks2/);

----------(end of table class code) ------

I want to add an index to the table class code above. Following the
example given here: -->
http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Cookbook.pod#Adding_Indexes_And_Functions_To_Your_SQL

I think I need to append the following code the the table class shown above:

-------------(start of index sub) ---------

sub sqlt_deploy_hook {
my ($self, $sqlt_table) = @_;

$sqlt_table->add_index(name => 'idx_name', fields => ['lsigntypid']);


}

-------------(end of index sub) ---------


Does the above look correct? What does the 'name' above reference in this context? Is it just a name for the index? Should I change it from 'idx_name' to something else?

Thanks

Bob Cochran
Greenbelt, Maryland, USA






_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


dbix-class at trout

May 28, 2008, 10:59 PM

Post #2 of 2 (107 views)
Permalink
Re: Adding Indexes To MySQL Database Tables in DBIC "result source" or "table classes" [In reply to]

On Mon, May 12, 2008 at 01:36:57PM -0400, Robert L Cochran wrote:
> I have a MySQL version 5 table named languagelist structured like this:

You seem to have accidentally posted this to the Catalyst list. I think you
meant this to go to the dbix-class list?

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.