#265 open
Pascal

prefix table names in the database

Reported by Pascal | March 30th, 2009 @ 12:08 AM

With all those engines creating tables in the database, the 'regular' app table names may clash with those.

An example: my app needs an Activity model with a 'activities' table, but one engine already uses that table name.

I propose to re-base every model classes in adva to a class named like Adva::ActiveRecordBase which will look like this:

module Adva
  class ActiveRecordBase < ActiveRecord::Base
    def self.table_name_prefix
      "adva_"
    end
  end
end

With this new base class, every adva model will use a table name prefix (thanx to AR).

Note that I put the class in the Adva module, I think every adva models should also be namedspaced, so not only the tablenames are but also the model classes.

Thanx for listening.

Pascal

Comments and changes to this ticket

  • Clemens Kofler

    Clemens Kofler March 30th, 2009 @ 10:27 PM

    This sounds like a pretty good idea to me. We should definitely look into that. Thanks for suggesting it, Pascal!

  • Marko Seppä

    Marko Seppä June 18th, 2009 @ 04:21 PM

    • State changed from “new” to “open”

    Added to product backlog as 'namespacing adva-cms'.

  • Pascal

    Pascal June 18th, 2009 @ 09:37 PM

    BTW, I implemented such a system in an engine I developed.
    For the base class to act correctly with STI we need also to tell AR it's an abstract class.
    So here is the revised base class:

    module Adva

    class ActiveRecordBase < ActiveRecord::Base
      def self.table_name_prefix
        "adva_"
      end
    
      self.abstract_class = true
    end
    

    end

    Concerning namespacing the adva classes such as the models, I also did implement that, I had issues when specifying associations on the models. To work around these issues I had to add the :class_name options to every association to include the namespace, like:
    module Adva

    class Section < ActiveRecordBase
      has_many :articles, :class_names => 'Adva::Article'
    end
    

    end

    I stay tuned.

    Regards,

    Pascal

  • Mark Lee
  • Linda

    Linda March 22nd, 2021 @ 03:47 PM

    This was so helpful content that they share about the prefix tables used in the database BIM Construction and also the code that helps in doing it more about it is very well explained in the content shared here thanks a lot for sharing this

  • meocatshirt

    meocatshirt March 27th, 2021 @ 04:03 PM

    Placeit has lots of puppy T-blouse templates and cool shirt ideas to be had to choose from, together with the only beneath: If you are seeking to grow your on line store or simply want to branch out into something new, there’s continually the possibility of starting a business of custom-designed products. ew people cat shirt There are severa fulfillment apps available for Shopify which include dropshipping from Chinese shops and all that.

  • Charlie

    Charlie April 2nd, 2021 @ 02:38 PM

    Get 30% off on COVENANT EYES PROMO CODE, Now stop pornography and live clean. The computer-wide transparency enables the individual the influence of interactions to avoid watching porn and maintain lasting liberty & dignity. Bring the Covenant Eyes Coupon Code and Encourages yourself to Leave Pornography, Through tracking your gadgets and submitting a summary of your computer behavior to a trusted friend or ally, Covenant Eyes lets you avoid watching porn.

  • Charlie

    Charlie April 2nd, 2021 @ 02:38 PM

    Get 30% off on COVENANT EYES PROMO CODE, Now stop pornography and live clean. The computer-wide transparency enables the individual the influence of interactions to avoid watching porn and maintain lasting liberty & dignity. Bring the Covenant Eyes Coupon Code and Encourages yourself to Leave Pornography, Through tracking your gadgets and submitting a summary of your computer behavior to a trusted friend or ally, Covenant Eyes lets you avoid watching porn.

  • Derick

    Derick April 12th, 2021 @ 05:50 PM

    Good to know about this one. i am really happy to know about this one from here. photo editing services real estateIt is a good things that make me to know about new things from here. Thank you all.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<p>Cutting edge cms, blog, wiki, forum ... plattform.</p>

<p>Find the code on <a href="http://github.com/svenfuchs/adva_cms/tree/master">GitHub: adva cms</a></p>

<p>Part of the business application framework <a href="http://www.advabest.org/">adva best</a>.</p>

Pages