Commit 14f31b8b authored by Alex Ives's avatar Alex Ives

Fix for untracked files

Relates to https://gitlab.com/gitlab-org/gitlab/issues/233778
parent 1148bfaf
......@@ -125,12 +125,29 @@ class SchemaRegenerator
# In order to properly reset the database and re-run migrations
# the schema migrations for new migrations must be removed.
def remove_schema_migration_files
git_command = "git diff --name-only --diff-filter=A #{merge_base} -- #{SCHEMA_MIGRATIONS_DIR}"
run(git_command).chomp.split("\n").each do |schema_migration|
(untracked_schema_migrations + commited_schema_migrations).each do |schema_migration|
FileUtils.rm(schema_migration)
end
end
##
# List of untracked schema migrations
#
# Get a list of schema migrations that are not tracked so we can remove them
def untracked_schema_migrations
git_command = "git ls-files --others --exclude-standard -- #{SCHEMA_MIGRATIONS_DIR}"
run(git_command).chomp.split("\n")
end
##
# List of untracked schema migrations
#
# Get a list of schema migrations that have been committed since the last
def commited_schema_migrations
git_command = "git diff --name-only --diff-filter=A #{merge_base} -- #{SCHEMA_MIGRATIONS_DIR}"
run(git_command).chomp.split("\n")
end
##
# Run rake task to reset the database.
def reset_db
......
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