#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

  • 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.

  • Derick
  • Erika Maer

    Erika Maer April 27th, 2021 @ 06:42 PM

    Is it Academized a safe writing service for me? I want to get more information about this company and its writers. Who will tell essayservices.review ?

  • brandereplica
  • Derick

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