Hi Tomas, That sounds interesting indeed. IIRC we already had this discussion (maybe with Martin) at the hackfest. And we also broached the COMMENT option of MySQL which is used for that. There is also the same kind of thing for postgresql ( https://www.postgresql.org/docs/current/static/sql-comment.html) Maybe DBIx::Class handles a common way to access this information? I did not find anything in the docs but did not search for a long time.
Cheers, Jonathan On Thu, 5 Jan 2017 at 20:32 Tomas Cohen Arazi <tomasco...@gmail.com> wrote: > In the process of writing a script for generating swagger object > definitions our of DBIC schemas (for sort-of scaffolding them making easier > to add REST endpoints) I resumed some talks we had at Marseille, and also > picked some previous work from Lari on automating the Koha::Object <-> > Swagger translation. > > One thing that would be handy for this process, is to add the column > descriptions to the schema files. This can be accomplished like this > example (for Koha::Schema::Result::BorrowerAttributeType): > > +__PACKAGE__->add_columns( > + "+code" => { > + koha_description => "Unique key used to identify the attribute > type" > + }, > + "+description" => > + { koha_description => "Description for the attribute type" }, > + "+repeatable" => { > + koha_description => > + "Defines if a patron can have multiple values for the > attribute type" > + }, > + "+unique_id" => { > + koha_description => "Defines if the assinged value need to be > unique" > + }, > + "+opac_display" => { > + koha_description => > + "Defines if the attribute is visible to patrons on their > account in the OPAC or not" > + }, > + "+opac_editable" => { > + koha_description => > + "Defines if the attribute is editable by patrons on their > account in the OPAC or not" > + }, > + "+staff_searchable" => { > + koha_description => > + "Defines if the attribute is searchable via the patron search > in the staff client" > + }, > + "+authorised_value_category" => { > + koha_description => > + "Foreign key from authorised_values that links this attribute > to an authorized value category" > + }, > + "+display_checkout" => { > + koha_description => > + "Defines if the attribute is displayed in checkout screens" > + }, > + "+category_code" => { > + koha_description => > + "Defines a constraint on a patron category for the attribute > type" > + }, > + "+class" => > + { koha_description => "Defines a class for grouping attributes" } > +); > > This way we can have really simple access to those descriptions we already > have in kohastructure.sql: > > my $columns_info = > Koha::Database->new->schema->resultset('BorrowerAttributeType') > ->result_source->columns_info; > > foreach $key ( keys %{ $columns_info } ) { > print "Column: $key | Description: " . > $columns_info->{$key}->{koha_description}; > } > > This could be an easy initial task for academy bugs. > > Opinions? We will need this at some point if we would change our workflow > and have DB structure handled by DBIC. > > Anyway, I'll send a pull request to Jonathan so he adds this handy (and > perfectible) script to his koha-misc4dev repository. This will make it > available on kohadevbox right out-of-the-box. I'll then try to document it > on Kyle's Koha Developer Handbook, which we all should add our bits of > knowledge! > > Looking forward to your feedback! > > -- > Tomás Cohen Arazi > Theke Solutions (https://theke.io <http://theke.io/>) > ✆ +54 9351 3513384 <+54%209%20351%20351-3384> > GPG: B2F3C15F > _______________________________________________ > Koha-devel mailing list > Koha-devel@lists.koha-community.org > http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel > website : http://www.koha-community.org/ > git : http://git.koha-community.org/ > bugs : http://bugs.koha-community.org/
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/