1. Packages
  2. Sql Provider
  3. API Docs
  4. MigrateDirectory
sql 0.5.0 published on Monday, Apr 14, 2025 by paultyng

sql.MigrateDirectory

Explore with Pulumi AI

sql logo
sql 0.5.0 published on Monday, Apr 14, 2025 by paultyng

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as sql from "@pulumi/sql";
    
    const db = new sql.MigrateDirectory("db", {path: `${path.module}/migrations`});
    const users = sql.getQuery({
        query: "select * from users",
    });
    export const rowcount = users.then(users => users.results).length;
    
    import pulumi
    import pulumi_sql as sql
    
    db = sql.MigrateDirectory("db", path=f"{path['module']}/migrations")
    users = sql.get_query(query="select * from users")
    pulumi.export("rowcount", len(users.results))
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/sql/sql"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := sql.NewMigrateDirectory(ctx, "db", &sql.MigrateDirectoryArgs{
    			Path: pulumi.Sprintf("%v/migrations", path.Module),
    		})
    		if err != nil {
    			return err
    		}
    		users, err := sql.GetQuery(ctx, &sql.GetQueryArgs{
    			Query: "select * from users",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("rowcount", pulumi.Int(len(users.Results)))
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Sql = Pulumi.Sql;
    
    return await Deployment.RunAsync(() => 
    {
        var db = new Sql.MigrateDirectory("db", new()
        {
            Path = $"{path.Module}/migrations",
        });
    
        var users = Sql.GetQuery.Invoke(new()
        {
            Query = "select * from users",
        });
    
        return new Dictionary<string, object?>
        {
            ["rowcount"] = users.Apply(getQueryResult => getQueryResult.Results).Length,
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.sql.MigrateDirectory;
    import com.pulumi.sql.MigrateDirectoryArgs;
    import com.pulumi.sql.SqlFunctions;
    import com.pulumi.sql.inputs.GetQueryArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var db = new MigrateDirectory("db", MigrateDirectoryArgs.builder()
                .path(String.format("%s/migrations", path.module()))
                .build());
    
            final var users = SqlFunctions.getQuery(GetQueryArgs.builder()
                .query("select * from users")
                .build());
    
            ctx.export("rowcount", users.applyValue(getQueryResult -> getQueryResult.results()).length());
        }
    }
    
    Coming soon!
    

    Create MigrateDirectory Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new MigrateDirectory(name: string, args: MigrateDirectoryArgs, opts?: CustomResourceOptions);
    @overload
    def MigrateDirectory(resource_name: str,
                         args: MigrateDirectoryArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def MigrateDirectory(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         path: Optional[str] = None,
                         single_file_split: Optional[str] = None)
    func NewMigrateDirectory(ctx *Context, name string, args MigrateDirectoryArgs, opts ...ResourceOption) (*MigrateDirectory, error)
    public MigrateDirectory(string name, MigrateDirectoryArgs args, CustomResourceOptions? opts = null)
    public MigrateDirectory(String name, MigrateDirectoryArgs args)
    public MigrateDirectory(String name, MigrateDirectoryArgs args, CustomResourceOptions options)
    
    type: sql:MigrateDirectory
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args MigrateDirectoryArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args MigrateDirectoryArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args MigrateDirectoryArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MigrateDirectoryArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args MigrateDirectoryArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var migrateDirectoryResource = new Sql.MigrateDirectory("migrateDirectoryResource", new()
    {
        Path = "string",
        SingleFileSplit = "string",
    });
    
    example, err := sql.NewMigrateDirectory(ctx, "migrateDirectoryResource", &sql.MigrateDirectoryArgs{
    	Path:            pulumi.String("string"),
    	SingleFileSplit: pulumi.String("string"),
    })
    
    var migrateDirectoryResource = new MigrateDirectory("migrateDirectoryResource", MigrateDirectoryArgs.builder()
        .path("string")
        .singleFileSplit("string")
        .build());
    
    migrate_directory_resource = sql.MigrateDirectory("migrateDirectoryResource",
        path="string",
        single_file_split="string")
    
    const migrateDirectoryResource = new sql.MigrateDirectory("migrateDirectoryResource", {
        path: "string",
        singleFileSplit: "string",
    });
    
    type: sql:MigrateDirectory
    properties:
        path: string
        singleFileSplit: string
    

    MigrateDirectory Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The MigrateDirectory resource accepts the following input properties:

    Path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    SingleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    Path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    SingleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    path String
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit String
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    path str
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    single_file_split str
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    path String
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit String
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).

    Outputs

    All input properties are implicitly available as output properties. Additionally, the MigrateDirectory resource produces the following output properties:

    CompleteMigrations List<MigrateDirectoryCompleteMigration>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    Id string
    The provider-assigned unique ID for this managed resource.
    CompleteMigrations []MigrateDirectoryCompleteMigration
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    Id string
    The provider-assigned unique ID for this managed resource.
    completeMigrations List<MigrateDirectoryCompleteMigration>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    id String
    The provider-assigned unique ID for this managed resource.
    completeMigrations MigrateDirectoryCompleteMigration[]
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    id string
    The provider-assigned unique ID for this managed resource.
    complete_migrations Sequence[MigrateDirectoryCompleteMigration]
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    id str
    The provider-assigned unique ID for this managed resource.
    completeMigrations List<Property Map>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing MigrateDirectory Resource

    Get an existing MigrateDirectory resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: MigrateDirectoryState, opts?: CustomResourceOptions): MigrateDirectory
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            complete_migrations: Optional[Sequence[MigrateDirectoryCompleteMigrationArgs]] = None,
            path: Optional[str] = None,
            single_file_split: Optional[str] = None) -> MigrateDirectory
    func GetMigrateDirectory(ctx *Context, name string, id IDInput, state *MigrateDirectoryState, opts ...ResourceOption) (*MigrateDirectory, error)
    public static MigrateDirectory Get(string name, Input<string> id, MigrateDirectoryState? state, CustomResourceOptions? opts = null)
    public static MigrateDirectory get(String name, Output<String> id, MigrateDirectoryState state, CustomResourceOptions options)
    resources:  _:    type: sql:MigrateDirectory    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    CompleteMigrations List<MigrateDirectoryCompleteMigration>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    Path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    SingleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    CompleteMigrations []MigrateDirectoryCompleteMigrationArgs
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    Path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    SingleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    completeMigrations List<MigrateDirectoryCompleteMigration>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    path String
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit String
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    completeMigrations MigrateDirectoryCompleteMigration[]
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    path string
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit string
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    complete_migrations Sequence[MigrateDirectoryCompleteMigrationArgs]
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    path str
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    single_file_split str
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).
    completeMigrations List<Property Map>
    The completed migrations that have been run against your database. This list is used as storage to migrate down or as a trigger for downstream dependencies.
    path String
    The path of the SQL migration files. For a path relative to the current module, use path.module.
    singleFileSplit String
    Set this to a value if your migration up and down are in a single file, split on some constant string (ie. in the case of shmig you would use -- ==== DOWN ====).

    Supporting Types

    MigrateDirectoryCompleteMigration, MigrateDirectoryCompleteMigrationArgs

    Down string
    Id string
    Up string
    Down string
    Id string
    Up string
    down String
    id String
    up String
    down string
    id string
    up string
    down str
    id str
    up str
    down String
    id String
    up String

    Package Details

    Repository
    sql paultyng/terraform-provider-sql
    License
    Notes
    This Pulumi package is based on the sql Terraform Provider.
    sql logo
    sql 0.5.0 published on Monday, Apr 14, 2025 by paultyng