예제 #1
0
        protected override void ProcessRecord()
        {
            var seederDir = Configuration.GetMigratioDir(MigrationRootDir, ConfigFile, MigratioDirectory.Seeders);

            if (!FileManager.DirectoryExists(seederDir))
            {
                FileManager.CreateDirectory(seederDir);
                WriteObject($"Created directory {seederDir}");
            }

            var fileName = Path.Combine(seederDir,
                                        $"{FileManager.GetFilePrefix()}_{FileManager.GetFormattedName(Name)}.sql");

            if (FileManager.FileExists(fileName))
            {
                WriteObject(new MgResult {
                    Successful = false, Details = $"File {fileName} already exists"
                });
            }
            else
            {
                FileManager.CreateFile(fileName);
                WriteObject(new MgResult {
                    Successful = true, Details = $"Created file {fileName}"
                });
            }
        }
예제 #2
0
        protected override void ProcessRecord()
        {
            var rolloutDir  = Configuration.GetMigratioDir(MigrationRootDir, ConfigFile, MigratioDirectory.Rollout);
            var rollbackDir = Configuration.GetMigratioDir(MigrationRootDir, ConfigFile, MigratioDirectory.Rollback);
            var dirs        = new[] { rolloutDir, rollbackDir };

            foreach (var dir in dirs)
            {
                if (FileManager.DirectoryExists(dir))
                {
                    continue;
                }
                FileManager.CreateDirectory(dir);
                WriteObject($"Created directory {dir}");
            }

            foreach (var dir in dirs)
            {
                var fileName = Path.Combine(dir,
                                            $"{FileManager.GetFilePrefix()}_{FileManager.GetFormattedName(Name)}.sql");
                if (FileManager.FileExists(fileName))
                {
                    WriteWarning($"File {fileName} already exists");
                    WriteObject(new MgResult {
                        Successful = true, Details = $"File {fileName} already exists"
                    });
                }
                else
                {
                    FileManager.CreateFile(fileName);
                    WriteObject(new MgResult {
                        Successful = true, Details = $"Created file {fileName}"
                    });
                }
            }
        }