Commit 381b7065 authored by Rémy Coutable's avatar Rémy Coutable

Move EE-specific migrations under ee/db/

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent d3061333
......@@ -13,11 +13,24 @@ AllCops:
- 'db/*'
- 'db/fixtures/**/*'
- 'db/geo/*'
- 'ee/db/geo/*'
- 'tmp/**/*'
- 'bin/**/*'
- 'generator_templates/**/*'
- 'builds/**/*'
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
Style/MutableConstant:
Enabled: true
Exclude:
- 'db/migrate/**/*'
- 'db/post_migrate/**/*'
- 'db/geo/migrate/**/*'
- 'ee/db/migrate/**/*'
- 'ee/db/post_migrate/**/*'
- 'ee/db/geo/migrate/**/*'
# Gitlab ###################################################################
Gitlab/ModuleWithInstanceVariables:
......
......@@ -12,3 +12,12 @@ unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']
ActiveRecord::Migrator.migrations_paths << path
end
end
migrate_paths = Rails.application.config.paths['db/migrate'].to_a
migrate_paths.each do |migrate_path|
absolute_migrate_path = Pathname.new(migrate_path).realpath(Rails.root)
ee_migrate_path = Rails.root.join('ee/', absolute_migrate_path.relative_path_from(Rails.root))
Rails.application.config.paths['db/migrate'] << ee_migrate_path.to_s
ActiveRecord::Migrator.migrations_paths << ee_migrate_path.to_s
end
......@@ -167,7 +167,7 @@ otherwise it may fail with an encryption error.
Secondary Geo nodes track data about what has been downloaded in a second
PostgreSQL database that is distinct from the production GitLab database.
The database configuration is set in `config/database_geo.yml`.
`db/geo` contains the schema and migrations for this database.
`ee/db/geo` contains the schema and migrations for this database.
To write a migration for the database, use the `GeoMigrationGenerator`:
......
......@@ -12,6 +12,6 @@ class GeoMigrationGenerator < ActiveRecord::Generators::MigrationGenerator
def create_migration_file
set_local_assigns!
validate_file_name!
migration_template @migration_template, "db/geo/migrate/#{file_name}.rb"
migration_template @migration_template, "ee/db/geo/migrate/#{file_name}.rb"
end
end
......@@ -5,7 +5,7 @@ module Gitlab
DATABASE_CONFIG = 'config/database.yml'.freeze
GEO_DATABASE_CONFIG = 'config/database_geo.yml'.freeze
GEO_DB_DIR = 'db/geo'.freeze
GEO_DB_DIR = 'ee/db/geo'.freeze
def method_missing(method_name, *args, &block)
with_geo_db do
......
......@@ -41,14 +41,14 @@ namespace :geo do
puts "Current version: #{Gitlab::Geo::DatabaseTasks.version}"
end
desc 'Drops and recreates the database from db/geo/schema.rb for the current environment and loads the seeds.'
desc 'Drops and recreates the database from ee/db/geo/schema.rb for the current environment and loads the seeds.'
task reset: [:environment] do
ns['drop'].invoke
ns['create'].invoke
ns['setup'].invoke
end
desc 'Load the seed data from db/geo/seeds.rb'
desc 'Load the seed data from ee/db/geo/seeds.rb'
task seed: [:environment] do
ns['abort_if_pending_migrations'].invoke
......@@ -97,7 +97,7 @@ namespace :geo do
Gitlab::Geo::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
end
desc 'Create a db/geo/schema.rb file that is portable against any DB supported by AR'
desc 'Create a ee/db/geo/schema.rb file that is portable against any DB supported by AR'
task dump: [:environment] do
Gitlab::Geo::DatabaseTasks::Schema.dump
......
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20171103152048_geo_drain_redis_queues')
require Rails.root.join('ee', 'db', 'post_migrate', '20171103152048_geo_drain_redis_queues')
describe GeoDrainRedisQueues, :clean_gitlab_redis_shared_state do
subject(:migration) { described_class.new }
......
require "spec_helper"
require Rails.root.join("db", "post_migrate", "20170811082658_remove_system_hook_from_geo_nodes.rb")
require 'spec_helper'
require Rails.root.join('ee', 'db', 'post_migrate', '20170811082658_remove_system_hook_from_geo_nodes.rb')
describe RemoveSystemHookFromGeoNodes, :migration do
let(:geo_nodes) { table(:geo_nodes) }
......
require 'spec_helper'
require Rails.root.join('db', 'migrate', '20170626202753_update_authorized_keys_file.rb')
require Rails.root.join('ee', 'db', 'migrate', '20170626202753_update_authorized_keys_file.rb')
describe UpdateAuthorizedKeysFile, :migration do
let(:migration) { described_class.new }
......
......@@ -5,7 +5,11 @@ require 'spec_helper'
describe ActiveRecord::Schema do
let(:latest_migration_timestamp) do
migrations = Dir[Rails.root.join('db', 'migrate', '*'), Rails.root.join('db', 'post_migrate', '*')]
migrations_paths =
%w[db ee/db].product(%w[migrate post_migrate]).each_with_object([]) do |migration_dir, memo|
memo << Rails.root.join(*migration_dir, '*')
end
migrations = Dir[*migrations_paths]
migrations.map { |migration| File.basename(migration).split('_').first.to_i }.max
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment