diff --git a/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb b/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb new file mode 100644 index 000000000..6907c6fdf --- /dev/null +++ b/db/migrate/20150601043133_add_order_index_to_build_list_packages.rb @@ -0,0 +1,10 @@ +class AddOrderIndexToBuildListPackages < ActiveRecord::Migration + def up + add_index :build_list_packages, name: :build_list_packages_ordering, + expression: "lower(build_list_packages.name) ASC, length(build_list_packages.name) ASC" + end + + def down + remove_index :build_list_packages, name: :build_list_packages_ordering, if_exists: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f34e3bfc..594de1336 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150529034800) do +ActiveRecord::Schema.define(version: 20150601043133) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -102,6 +102,7 @@ ActiveRecord::Schema.define(version: 20150529034800) do t.string "sha1" t.integer "epoch" t.text "dependent_packages" + t.index :name => "build_list_packages_ordering", :expression => "lower((name)::text), length((name)::text)" t.index ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id" t.index ["build_list_id"], :name => "index_build_list_packages_on_build_list_id" t.index ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id"